From dcd27aace180737adaddc79c00c181816fc6e162 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 16 Jul 2025 17:53:47 +0200 Subject: [PATCH 1/4] gh-127146: Emscripten: Don't need to avoid unpaired surrogate anymore (#136707) This might have been fixed by gh-136624, or by some Emscripten change. In any case, it no longer seems to be needed. --- Lib/test/test_warnings/__init__.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index 5c3b1250ceb045..f89e94449b3031 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -555,13 +555,7 @@ def test_warn_explicit_non_ascii_filename(self): with self.module.catch_warnings(record=True) as w: self.module.resetwarnings() self.module.filterwarnings("always", category=UserWarning) - filenames = ["nonascii\xe9\u20ac"] - if not support.is_emscripten: - # JavaScript does not like surrogates. - # Invalid UTF-8 leading byte 0x80 encountered when - # deserializing a UTF-8 string in wasm memory to a JS - # string! - filenames.append("surrogate\udc80") + filenames = ["nonascii\xe9\u20ac", "surrogate\udc80"] for filename in filenames: try: os.fsencode(filename) From 69d8fe50ddc4dbe757c9929a532e2e882f0261ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= Date: Wed, 16 Jul 2025 18:34:14 +0200 Subject: [PATCH 2/4] gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) --- Doc/library/importlib.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index ea5a77028683b3..4f374be778d6b3 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -206,6 +206,10 @@ Functions :exc:`ModuleNotFoundError` is raised when the module being reloaded lacks a :class:`~importlib.machinery.ModuleSpec`. + .. warning:: + This function is not thread-safe. Calling it from multiple threads can result + in unexpected behavior. It's recommended to use the :class:`threading.Lock` + or other synchronization primitives for thread-safe module reloading. :mod:`importlib.abc` -- Abstract base classes related to import --------------------------------------------------------------- From b7d722547bcc9e92dca4837b9fdbe7457788820b Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Wed, 16 Jul 2025 22:09:08 +0530 Subject: [PATCH 3/4] gh-136669: build `_asyncio` as static module (#136670) `_asyncio` is now built as a static module so that thread states can be accessed directly via registers and avoids the overhead of function call. --- .../Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst | 1 + Modules/Setup.stdlib.in | 7 ++++++- Modules/_remote_debugging_module.c | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst diff --git a/Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst b/Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst new file mode 100644 index 00000000000000..0d93397ff35d0b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst @@ -0,0 +1 @@ +:mod:`!_asyncio` is now statically linked for improved performance. diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 3a38a60a152e8c..86c8eb27c0a6c7 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -32,7 +32,6 @@ ############################################################################ # Modules that should always be present (POSIX and Windows): @MODULE_ARRAY_TRUE@array arraymodule.c -@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c @MODULE__BISECT_TRUE@_bisect _bisectmodule.c @MODULE__CSV_TRUE@_csv _csv.c @MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c @@ -193,3 +192,9 @@ # Limited API template modules; must be built as shared modules. @MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c @MODULE_XXLIMITED_35_TRUE@xxlimited_35 xxlimited_35.c + + +# for performance +*static* + +@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c diff --git a/Modules/_remote_debugging_module.c b/Modules/_remote_debugging_module.c index d72031137e0a4e..b50e5e403a1a19 100644 --- a/Modules/_remote_debugging_module.c +++ b/Modules/_remote_debugging_module.c @@ -811,7 +811,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle) } #elif defined(__linux__) // On Linux, search for asyncio debug in executable or DLL - address = search_linux_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython"); + address = search_linux_map_for_section(handle, "AsyncioDebug", "python"); if (address == 0) { // Error out: 'python' substring covers both executable and DLL PyObject *exc = PyErr_GetRaisedException(); @@ -820,10 +820,10 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle) } #elif defined(__APPLE__) && TARGET_OS_OSX // On macOS, try libpython first, then fall back to python - address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython"); + address = search_map_for_section(handle, "AsyncioDebug", "libpython"); if (address == 0) { PyErr_Clear(); - address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython"); + address = search_map_for_section(handle, "AsyncioDebug", "python"); } if (address == 0) { // Error out: 'python' substring covers both executable and DLL From 180b3eb697bf5bb0088f3f35ef2d3675f9fff04f Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem <4048546+olehermanse@users.noreply.github.com> Date: Wed, 16 Jul 2025 19:29:30 +0200 Subject: [PATCH 4/4] fix traceback.FrameSummary docstring by adding end_lineno, colno, and end_colno (#136716) --- Lib/traceback.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/traceback.py b/Lib/traceback.py index a1f175dbbaa421..31aa8695735f2b 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -287,6 +287,12 @@ class FrameSummary: of code that was running when the frame was captured. - :attr:`locals` Either None if locals were not supplied, or a dict mapping the name to the repr() of the variable. + - :attr:`end_lineno` The last line number of the source code for this frame. + By default, it is set to lineno and indexation starts from 1. + - :attr:`colno` The column number of the source code for this frame. + By default, it is None and indexation starts from 0. + - :attr:`end_colno` The last column number of the source code for this frame. + By default, it is None and indexation starts from 0. """ __slots__ = ('filename', 'lineno', 'end_lineno', 'colno', 'end_colno',