Skip to content

Commit 78b2c6a

Browse files
Merge branch 'fix-gh-138577' of github.com:CuriousLearner/cpython into fix-gh-138577
* 'fix-gh-138577' of github.com:CuriousLearner/cpython: gh-146202: Create tmp_dir in regrtest worker (#146347) gh-144319: obtain SeLockMemoryPrivilege on Windows (#144928) gh-146199: Fix error handling in `code_richcompare` when `PyObject_RichCompareBool` fails (#146200) gh-146197: Include a bit more information in sys._emscripten_info.runtime (#146346) gh-135871: Reload lock internal state while spinning in `PyMutex_LockTimed` (gh-146064) gh-145719: Add `.efi` file detection in `mimetypes` (#145720)
2 parents a7c1de3 + ef1efcb commit 78b2c6a

File tree

15 files changed

+133
-18
lines changed

15 files changed

+133
-18
lines changed

Doc/using/cmdline.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,14 @@ conflict.
11321132
and kill the process. Only enable this in environments where the
11331133
huge-page pool is properly sized and fork-safety is not a concern.
11341134

1135+
On Windows you need a special privilege. See the
1136+
`Windows documentation for large pages
1137+
<https://learn.microsoft.com/windows/win32/memory/large-page-support>`_
1138+
for details. Python will fail on startup if the required privilege
1139+
`SeLockMemoryPrivilege
1140+
<https://learn.microsoft.com/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/lock-pages-in-memory>`_
1141+
is not held by the user.
1142+
11351143
.. versionadded:: 3.15
11361144

11371145

Doc/using/configure.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,18 @@ also be used to improve performance.
795795

796796
Even when compiled with this option, huge pages are **not** used at runtime
797797
unless the :envvar:`PYTHON_PYMALLOC_HUGEPAGES` environment variable is set
798-
to ``1``. This opt-in is required because huge pages carry risks on Linux:
799-
if the huge-page pool is exhausted, page faults (including copy-on-write
800-
faults after :func:`os.fork`) deliver ``SIGBUS`` and kill the process.
798+
to ``1``. This opt-in is required because huge pages
799+
800+
* carry risks on Linux: if the huge-page pool is exhausted, page faults
801+
(including copy-on-write faults after :func:`os.fork`) deliver ``SIGBUS``
802+
and kill the process.
803+
804+
* need a special privilege on Windows. See the `Windows documentation for large pages
805+
<https://learn.microsoft.com/windows/win32/memory/large-page-support>`_
806+
for details. Python will fail on startup if the required privilege
807+
`SeLockMemoryPrivilege
808+
<https://learn.microsoft.com/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/lock-pages-in-memory>`_
809+
is not held by the user.
801810

802811
The configure script checks that the platform supports ``MAP_HUGETLB``
803812
and emits a warning if it is not available.

Doc/whatsnew/3.15.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ mimetypes
842842
* Add ``application/sql`` and ``application/vnd.sqlite3``.
843843
(Contributed by Charlie Lin in :gh:`145698`.)
844844
* Add ``image/jxl``. (Contributed by Foolbar in :gh:`144213`.)
845+
* Add ``application/efi``. (Contributed by Charlie Lin in :gh:`145720`.)
845846
* Add the following MIME types:
846847

847848
- ``application/vnd.ms-cab-compressed`` for ``.cab`` extension

Lib/mimetypes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ def _default_mime_types():
478478
'.js' : 'text/javascript',
479479
'.mjs' : 'text/javascript',
480480
'.dcm' : 'application/dicom',
481+
'.efi' : 'application/efi',
481482
'.epub' : 'application/epub+zip',
482483
'.gz' : 'application/gzip',
483484
'.json' : 'application/json',

Lib/test/libregrtest/utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,6 @@ def get_temp_dir(tmp_dir: StrPath | None = None) -> StrPath:
452452
f"unexpectedly returned {tmp_dir!r} on WASI"
453453
)
454454
tmp_dir = os.path.join(tmp_dir, 'build')
455-
456-
# When get_temp_dir() is called in a worker process,
457-
# get_temp_dir() path is different than in the parent process
458-
# which is not a WASI process. So the parent does not create
459-
# the same "tmp_dir" than the test worker process.
460-
os.makedirs(tmp_dir, exist_ok=True)
461455
else:
462456
tmp_dir = tempfile.gettempdir()
463457

Lib/test/libregrtest/worker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def main() -> NoReturn:
127127
worker_json = sys.argv[1]
128128

129129
tmp_dir = get_temp_dir()
130+
# get_temp_dir() can be different in the worker and the parent process.
131+
# For example, if --tempdir option is used.
132+
os.makedirs(tmp_dir, exist_ok=True)
130133
work_dir = get_work_dir(tmp_dir, worker=True)
131134

132135
with exit_timeout():

Lib/test/test_code.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,18 @@ def test_stateless(self):
11641164
with self.assertRaises(Exception):
11651165
_testinternalcapi.verify_stateless_code(func)
11661166

1167+
def test_code_richcompare_raise_exception(self):
1168+
class BadStr(str):
1169+
def __eq__(self, _):
1170+
raise RuntimeError("Poison!")
1171+
1172+
__hash__ = str.__hash__
1173+
1174+
c1 = compile("pass", "test", "exec")
1175+
c2 = c1.replace(co_name=BadStr("poison"))
1176+
c3 = compile("pass", "poison", "exec")
1177+
with self.assertRaises(RuntimeError):
1178+
c2 == c3
11671179

11681180
def isinterned(s):
11691181
return s is sys.intern(('_' + s + '_')[1:-1])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve multithreaded scaling of PyMutex in low-contention scenarios by reloading the lock's internal state, without slowing down high-contention scenarios.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Comparison of code objects now handles errors correctly.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``application/efi`` MIME type to :mod:`mimetypes`.

0 commit comments

Comments
 (0)