]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
25 hours agogh-133403: Add type annotations to generate_levenshtein_examples.py (#143317)
John Seong [Sat, 18 Apr 2026 18:50:17 +0000 (02:50 +0800)] 
gh-133403: Add type annotations to generate_levenshtein_examples.py (#143317)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
25 hours agogh-148659: Export a few more functions required for external JITs (#148704)
Dino Viehland [Sat, 18 Apr 2026 18:32:22 +0000 (11:32 -0700)] 
gh-148659: Export a few more functions required for external JITs (#148704)

Export a few more functions required for external JITs

32 hours agogh-148653: Fix reference leaks in test_marshal introduced in gh-148698 (GH-148725)
Serhiy Storchaka [Sat, 18 Apr 2026 12:11:14 +0000 (15:11 +0300)] 
gh-148653: Fix reference leaks in test_marshal introduced in gh-148698 (GH-148725)

34 hours agogh-148688: Fix _BlocksOutputBuffer_Finish() double free (#148689)
Victor Stinner [Sat, 18 Apr 2026 09:56:56 +0000 (11:56 +0200)] 
gh-148688: Fix _BlocksOutputBuffer_Finish() double free (#148689)

If _BlocksOutputBuffer_Finish() fails (memory allocation failure),
PyBytesWriter_Discard() is called on the writer. Then if
_BlocksOutputBuffer_OnError() is called, it calls again
PyBytesWriter_Discard() causing a double free.

Fix _BlocksOutputBuffer_Finish() by setting buffer->writer to NULL,
so _BlocksOutputBuffer_OnError() does nothing instead of calling
PyBytesWriter_Discard() again.

35 hours agoAdd a new Sphinx `soft-deprecated` directive (#148630)
Hugo van Kemenade [Sat, 18 Apr 2026 08:37:54 +0000 (11:37 +0300)] 
Add a new Sphinx `soft-deprecated` directive (#148630)

Co-authored-by: Stan Ulbrych <stan@python.org>
36 hours agogh-148653: Fix some marshal errors related to recursive immutable objects (GH-148698)
Serhiy Storchaka [Sat, 18 Apr 2026 08:24:33 +0000 (11:24 +0300)] 
gh-148653: Fix some marshal errors related to recursive immutable objects (GH-148698)

Forbid marshalling recursive code, slice and frozendict objects which
cannot be correctly unmarshalled.
Reject invalid marshal data produced by marshalling recursive frozendict
objects which was previously incorrectly unmarshalled.
Add multiple tests for recursive data structures.

42 hours agogh-148639: Implement PEP 800 (typing.disjoint_base) (#148640)
Jelle Zijlstra [Sat, 18 Apr 2026 02:20:41 +0000 (19:20 -0700)] 
gh-148639: Implement PEP 800 (typing.disjoint_base) (#148640)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
44 hours agogh-148222: Fix NULL dereference bugs in genericaliasobject.c (#148226)
Prakash Sellathurai [Sat, 18 Apr 2026 00:21:13 +0000 (05:51 +0530)] 
gh-148222: Fix NULL dereference bugs in genericaliasobject.c (#148226)

2 days agogh-146393: Remove special character in optimizer_bytecodes.c (#148693)
Pieter Eendebak [Fri, 17 Apr 2026 16:52:16 +0000 (18:52 +0200)] 
gh-146393: Remove special character in optimizer_bytecodes.c (#148693)

2 days agogh-148651: Fix refcount leak in _zstd decompressor options (#148657)
Michael Bommarito [Fri, 17 Apr 2026 15:42:41 +0000 (11:42 -0400)] 
gh-148651: Fix refcount leak in _zstd decompressor options (#148657)

The option parsing in Modules/_zstd/decompressor.c had a missing Py_DECREF(value) before the early return -1 when PyLong_AsInt(key) fails. The identical code in Modules/_zstd/compressor.c line 158 has the fix.

2 days agogh-148683: Doc: fix misplaced pprint entries in What's New 3.15 (#148685)
Xuwz [Fri, 17 Apr 2026 14:13:41 +0000 (22:13 +0800)] 
gh-148683: Doc: fix misplaced pprint entries in What's New 3.15 (#148685)

Doc: fix misplaced pprint entries in What's New 3.15

2 days agogh-148484: Fix memory leak of iterator in array.array constructor (GH-148523)
Gleb Popov [Fri, 17 Apr 2026 12:13:44 +0000 (15:13 +0300)] 
gh-148484: Fix memory leak of iterator in array.array constructor (GH-148523)

2 days agogh-148464: Add missing ``__ctype_le/be__`` attributes for complex types in the ctype...
Sergey B Kirpichev [Fri, 17 Apr 2026 12:09:09 +0000 (15:09 +0300)] 
gh-148464: Add missing ``__ctype_le/be__`` attributes for complex types in the ctype module (GH-148485)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2 days agogh-148659: Export some internal functions for the JIT (PEP-523) (#148634)
Dino Viehland [Thu, 16 Apr 2026 23:55:03 +0000 (16:55 -0700)] 
gh-148659: Export some internal functions for the JIT (PEP-523) (#148634)

Export (as internal functions, not public ones) C API functions necessary to implement a JIT as a separate extension module.

3 days agogh-148535: Don't use gcc -fprofile-update=atomic flag on i686 (#148554)
Victor Stinner [Thu, 16 Apr 2026 17:13:25 +0000 (19:13 +0200)] 
gh-148535: Don't use gcc -fprofile-update=atomic flag on i686 (#148554)

The -fprofile-update=atomic flag was added to fix a random GCC
internal error on PGO build (gh-145801) caused by corruption of
profile data (.gcda files). The problem is that it makes the PGO
build way slower (up to 47x slower) on i686. Since the GCC internal
error was not seen on i686 so far, don't use -fprofile-update=atomic
on i686.

3 days agogh-146031: Allow keeping specialization enabled when specifying eval frame function...
Dino Viehland [Thu, 16 Apr 2026 16:44:26 +0000 (09:44 -0700)] 
gh-146031: Allow keeping specialization enabled when specifying eval frame function (#146032)

Allow keeping specialization enabled when specifying eval frame function

3 days agoGH-146128: Fix AArch64 multi-instruction constants and relocations (GH-148598)
Mark Shannon [Thu, 16 Apr 2026 14:33:09 +0000 (15:33 +0100)] 
GH-146128: Fix AArch64 multi-instruction constants and relocations (GH-148598)

Fix AArch64 multi-instruction constants and relocations

* Elimates rendundant orr xN, xN, 0xffff after 16 or 32 bit loads
* Merges adrp (21rx) and ldr (12) relocations into single 33rx relocation, when safe to do so.

3 days agoGH-145668: Add FOR_ITER specialization for virtual iterators. Specialize GET_ITER...
Mark Shannon [Thu, 16 Apr 2026 14:22:22 +0000 (15:22 +0100)] 
GH-145668: Add FOR_ITER specialization for virtual iterators. Specialize GET_ITER. (GH-147967)

* Add FOR_ITER_VIRTUAL to specialize FOR_ITER for virtual iterators
* Add GET_ITER_SELF to specialize GET_ITER for iterators (including generators)
* Add GET_ITER_VIRTUAL to specialize GET_ITER for iterables as virtual iterators
* Add new (internal) _tp_iteritem function slot to PyTypeObject
* Put limited RESUME at start of genexpr for free-threading. Fix up exception handling in genexpr

3 days agogh-146636: PEP 803: Reference documentation (GH-148013)
Petr Viktorin [Thu, 16 Apr 2026 12:17:44 +0000 (14:17 +0200)] 
gh-146636: PEP 803: Reference documentation (GH-148013)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
3 days agogh-100239: Specialize more binary operations using BINARY_OP_EXTEND (GH-128956)
Pieter Eendebak [Thu, 16 Apr 2026 08:22:41 +0000 (10:22 +0200)] 
gh-100239: Specialize more binary operations using BINARY_OP_EXTEND (GH-128956)

3 days agoDocs: Fix typos and a comment in enum.rst (#148156)
Havmaagen [Thu, 16 Apr 2026 05:53:29 +0000 (07:53 +0200)] 
Docs: Fix typos and a comment in enum.rst (#148156)

3 days agogh-148474: Fix `_Py_hexlify_simd` compilation with older clang (#148475)
Joshua Root [Thu, 16 Apr 2026 05:51:23 +0000 (15:51 +1000)] 
gh-148474: Fix `_Py_hexlify_simd` compilation with older clang (#148475)

3 days agogh-137814: Fix `__qualname__` of `__annotate__` (#137842)
Jelle Zijlstra [Thu, 16 Apr 2026 04:52:30 +0000 (21:52 -0700)] 
gh-137814: Fix `__qualname__` of `__annotate__` (#137842)

3 days agoAdd PyManager documentation for index signatures (GH-148631)
Steve Dower [Wed, 15 Apr 2026 21:48:14 +0000 (22:48 +0100)] 
Add PyManager documentation for index signatures (GH-148631)

4 days agogh-148100: Soft deprecate `re.match` and `re.Pattern.match` in favour of `prefixmatch...
Hugo van Kemenade [Wed, 15 Apr 2026 20:09:47 +0000 (23:09 +0300)] 
gh-148100: Soft deprecate `re.match` and `re.Pattern.match` in favour of `prefixmatch` (#148101)

4 days agogh-148604: change `ADD_OP(_POP_TOP, ...)` to `optimize_pop_top` in `optimizer_bytecod...
Neko Asakura [Wed, 15 Apr 2026 17:08:29 +0000 (13:08 -0400)] 
gh-148604: change `ADD_OP(_POP_TOP, ...)` to `optimize_pop_top` in `optimizer_bytecodes.c` (GH-148619)

4 days agoDocs: Use bash lexer for http.server CLI commands, not Python (#148612)
Hugo van Kemenade [Wed, 15 Apr 2026 15:18:49 +0000 (18:18 +0300)] 
Docs: Use bash lexer for http.server CLI commands, not Python (#148612)

4 days agogh-148600: Add Modules/_ssl_data_40.h data (#148601)
Victor Stinner [Wed, 15 Apr 2026 13:59:02 +0000 (15:59 +0200)] 
gh-148600: Add Modules/_ssl_data_40.h data (#148601)

The Modules/_ssl_data_40.h file was created with the commands:

python Tools/ssl/multissltests.py --steps=library --base-directory "$PWD/multissl" --openssl '4.0.0' --system Linux
python Tools/ssl/make_ssl_data.py multissl/src/openssl-4.0.0 Modules/_ssl_data_40.h

Update Modules/_ssl.c to include it on OpenSSL 4.0.0 and newer.

Update test_ssl for the new error message.

4 days agogh-143886: Ensure function annotations are returned in order of definition (#143888)
Carey Metcalfe [Wed, 15 Apr 2026 13:24:28 +0000 (09:24 -0400)] 
gh-143886: Ensure function annotations are returned in order of definition (#143888)

Ensure function annotations are returned in order of definition

Previously, when getting type annotations of a function, normal
arguments were returned before positional-only ones in the dictionary.
Since `functools.singledispatch` relies on this ordering being correct
to dispatch based on the type of the first argument, this issue was
causing incorrect registrations for functions with positional-only
arguments.

This commit updates how annotations are generated so that
positional-only arguments are generated and added to the dictionary
before normal arguments.

4 days agogh-148609: Remove unicode character in bytecodes.c (GH-148611)
Ken Jin [Wed, 15 Apr 2026 12:58:35 +0000 (20:58 +0800)] 
gh-148609: Remove unicode character in bytecodes.c (GH-148611)

Remove unicode character in bytecodes.c

4 days agogh-131798: Fix `_ITER_CHECK_RANGE` type in the JIT (#148607)
Wulian233 [Wed, 15 Apr 2026 12:22:55 +0000 (20:22 +0800)] 
gh-131798: Fix `_ITER_CHECK_RANGE`  type in the JIT (#148607)

4 days agogh-117716: Fix wave RIFF padding for data chunks (GH-145237)
Michiel W. Beijen [Wed, 15 Apr 2026 12:21:43 +0000 (14:21 +0200)] 
gh-117716: Fix wave RIFF padding for data chunks (GH-145237)

wave.Wave_write now writes the required RIFF pad byte when the data chunk
size is odd.

Update RIFF chunk size calculations in both header writing and header
patching so they include the alignment pad byte when present.

Add a regression test in test_wave.py that verifies
odd-sized writes are padded, RIFF size is correct, and roundtrip reads
preserve frame data.

4 days agogh-148390: fix undefined behavior of `memoryview(...).cast("?")` (#148454)
Bénédikt Tran [Wed, 15 Apr 2026 11:42:20 +0000 (13:42 +0200)] 
gh-148390: fix undefined behavior of `memoryview(...).cast("?")` (#148454)

4 days agogh-139038: Add whatsnew entry for jit unique reference tracking (GH-148572)
Pieter Eendebak [Wed, 15 Apr 2026 10:53:47 +0000 (12:53 +0200)] 
gh-139038: Add whatsnew entry for jit unique reference tracking (GH-148572)

Co-authored-by: Ken Jin <kenjin4096@gmail.com>
4 days agogh-147957: pop items from UserDict in LIFO order (gh-147958)
Anerdw [Wed, 15 Apr 2026 04:29:41 +0000 (23:29 -0500)] 
gh-147957: pop items from UserDict in LIFO order (gh-147958)

4 days agoGH-70647: Remove support for `%d` (and deprecate for `%e`) without year in `strptime...
Stan Ulbrych [Wed, 15 Apr 2026 00:15:27 +0000 (01:15 +0100)] 
GH-70647: Remove support for `%d` (and deprecate for `%e`) without year in `strptime()` (GH-144570)

* Add deprecation for %e with no year
* schedule `%e` for 3.17, and remove `%d` now

4 days agogh-148186: Improve `assertCountEqual` description in docs. (#148463)
Kliment Lamonov [Tue, 14 Apr 2026 23:39:16 +0000 (02:39 +0300)] 
gh-148186: Improve `assertCountEqual` description in docs. (#148463)

4 days agogh-137335: remove a mktemp use in multiprocessing.connection to avoid security scanne...
Gregory P. Smith [Tue, 14 Apr 2026 23:31:58 +0000 (16:31 -0700)] 
gh-137335: remove a mktemp use in multiprocessing.connection to avoid security scanner noise (GH-148578)

remove a mktemp use to avoid security scanner noise

4 days agotiny edit, fix a couple of minor typos in enum and sqlite3 docs (GH-148580)
Gregory P. Smith [Tue, 14 Apr 2026 23:29:35 +0000 (16:29 -0700)] 
tiny edit, fix a couple of minor typos in enum and sqlite3 docs (GH-148580)

pair of minor doc typo fixes

5 days agogh-146393: Use recorded type instead of instance in BINARY_OP (#148569)
Pieter Eendebak [Tue, 14 Apr 2026 20:11:42 +0000 (22:11 +0200)] 
gh-146393: Use recorded type instead of instance in BINARY_OP (#148569)

5 days agoGH-145278: freeze encodings (partially) and linecache (#148347)
Filipe Laíns [Tue, 14 Apr 2026 20:01:23 +0000 (21:01 +0100)] 
GH-145278: freeze encodings (partially) and linecache (#148347)

5 days agogh-146393: Optimize float division operations by mutating uniquely-referenced operand...
Pieter Eendebak [Tue, 14 Apr 2026 18:08:04 +0000 (20:08 +0200)] 
gh-146393: Optimize float division operations by mutating uniquely-referenced operands in place (JIT only) (GH-146397)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 days agogh-86519: Update docs for `prefixmatch` (#148096)
Hugo van Kemenade [Tue, 14 Apr 2026 17:15:06 +0000 (20:15 +0300)] 
gh-86519: Update docs for `prefixmatch` (#148096)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
5 days agogh-146563: add exception note for invalid Expat handler return values (#146565)
Bénédikt Tran [Tue, 14 Apr 2026 17:12:47 +0000 (19:12 +0200)] 
gh-146563: add exception note for invalid Expat handler return values (#146565)

5 days agogh-72406: Document argument ordering in argparse help output (#148534)
Santi Hernandez [Tue, 14 Apr 2026 16:24:16 +0000 (10:24 -0600)] 
gh-72406: Document argument ordering in argparse help output (#148534)

Co-authored-by: Savannah Ostrowski <savannah@python.org>
5 days agogh-131798: constant fold special method lookups in JIT (#148432)
Kumar Aditya [Tue, 14 Apr 2026 16:02:23 +0000 (21:32 +0530)] 
gh-131798: constant fold special method lookups in JIT (#148432)

5 days agogh-148047: Revert "GH-148047: Check early whether tail-calling is possible for MSVC...
Ken Jin [Tue, 14 Apr 2026 15:46:54 +0000 (23:46 +0800)] 
gh-148047: Revert "GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows (#148036)" (#148558)

This reverts commit cbd81d59cfea4f7b881642e804646da3a328a712.

5 days agogh-gh-131798: optimize `LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN` in the JIT (#148555)
Kumar Aditya [Tue, 14 Apr 2026 15:30:32 +0000 (21:00 +0530)] 
gh-gh-131798: optimize `LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN` in the JIT (#148555)

5 days agogh-133312: configure: add --enable-static-libpython-for-interpreter (#133313)
Geoffrey Thomas [Tue, 14 Apr 2026 15:26:19 +0000 (11:26 -0400)] 
gh-133312: configure: add --enable-static-libpython-for-interpreter (#133313)

This option changes the behavior of --enable-shared to continue to build
the libpython3.x.so shared library, but not use it for linking the
python3 interpreter executable. Instead, the executable is linked
directly against the libpython .o files as it would be with
--disable-shared.

There are two benefits of this change. First, libpython uses
thread-local storage, which is noticeably slower when used in a loaded
module instead of in the main program, because the main program can take
advantage of constant offsets from the thread state pointer but loaded
modules have to dynamically call a function __tls_get_addr() to
potentially allocate their thread-local storage area. (There is another
thread-local storage model for dynamic libraries which mitigates most of
this performance hit, but it comes at the cost of preventing
dlopen("libpython3.x.so"), which is a use case we want to preserve.)

Second, this improves the user experience around relocatable Python a
little bit, in that we don't need to use an $ORIGIN-relative path to
locate libpython3.x.so, which has some mild benefits around musl (which
does not support $ORIGIN-relative DT_NEEDED, only $ORIGIN-relative
DT_RPATH/DT_RUNPATH), users who want to make the interpreter setuid or
setcap (which prevents processing $ORIGIN), etc.

5 days agogh-131798: Constant-fold `_CONTAINS_OP_DICT` for frozendict (GH-148548)
Wulian233 [Tue, 14 Apr 2026 15:04:28 +0000 (23:04 +0800)] 
gh-131798: Constant-fold `_CONTAINS_OP_DICT` for frozendict (GH-148548)

5 days agogh-148510: restore `func_version` check in `_LOAD_ATTR_PROPERTY_FRAME` (GH-148528)
Neko Asakura [Tue, 14 Apr 2026 14:44:39 +0000 (10:44 -0400)] 
gh-148510: restore `func_version` check in `_LOAD_ATTR_PROPERTY_FRAME` (GH-148528)

5 days agogh-148192: Fix Generator._make_boundary behavior with CRLF line endings. (#148193)
Henry Jones [Tue, 14 Apr 2026 13:10:08 +0000 (01:10 +1200)] 
gh-148192: Fix Generator._make_boundary behavior with CRLF line endings. (#148193)

The Generator._make_boundary regex did not match on boundary phrases correctly when using CRLF line endings due to re.MULTILINE not considering \r\n as a line ending.

5 days agogh-134551: Add t-strings support to pprint (#134577)
Loïc Simon [Tue, 14 Apr 2026 11:37:41 +0000 (13:37 +0200)] 
gh-134551: Add t-strings support to pprint (#134577)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
5 days agogh-148378: Allow multiple consecutive recording ops per macro op (GH-148496)
Hai Zhu [Tue, 14 Apr 2026 11:26:53 +0000 (19:26 +0800)] 
gh-148378: Allow multiple consecutive recording ops per macro op (GH-148496)

5 days agogh-143955: Prevent schema drift false-positives in asyncio tools tests (#148525)
Bartosz Sławecki [Tue, 14 Apr 2026 09:29:01 +0000 (11:29 +0200)] 
gh-143955: Prevent schema drift false-positives in asyncio tools tests (#148525)

5 days agogh-148487: Fix issues in `test_add_python_opts` (#148507)
Stan Ulbrych [Tue, 14 Apr 2026 06:45:26 +0000 (07:45 +0100)] 
gh-148487: Fix issues in `test_add_python_opts` (#148507)

5 days agogh-148515: make `optimizer_generator` respect multiple caches (#148524)
Neko Asakura [Tue, 14 Apr 2026 04:51:05 +0000 (00:51 -0400)] 
gh-148515: make `optimizer_generator` respect multiple caches (#148524)

5 days agogh-148508: Add resilience to SSL preauth tests on iOS (#148536)
Russell Keith-Magee [Tue, 14 Apr 2026 03:12:37 +0000 (11:12 +0800)] 
gh-148508: Add resilience to SSL preauth tests on iOS (#148536)

Adds handling for a test case seen in the iOS SSL tests where an SSL connection fails to
handshake correctly.

5 days agogh-148252: Fix stack depth calculation in binary reader on 32-bit platforms (#148253)
Pablo Galindo Salgado [Mon, 13 Apr 2026 22:43:55 +0000 (23:43 +0100)] 
gh-148252: Fix stack depth calculation in binary reader on 32-bit platforms (#148253)

Compute ``final_depth`` in ``decode_stack_pop_push()`` and
``decode_stack_suffix()`` using ``uint64_t`` before validating it.

On 32-bit builds, using ``size_t`` arithmetic for ``keep + push`` can wrap
for large input values, causing the later bounds check to validate the wrong
final depth. Using a widened type keeps the validation aligned with the
actual result.

5 days agogh-148370: prevent quadratic behavior in `configparser.ParsingError.combine` (#148452)
Bénédikt Tran [Mon, 13 Apr 2026 22:32:54 +0000 (00:32 +0200)] 
gh-148370: prevent quadratic behavior in `configparser.ParsingError.combine` (#148452)

5 days agogh-148178: Validate remote debug offset tables on load (#148187)
Pablo Galindo Salgado [Mon, 13 Apr 2026 22:22:23 +0000 (23:22 +0100)] 
gh-148178: Validate remote debug offset tables on load (#148187)

Treat the debug offset tables read from a target process as untrusted input
and validate them before the unwinder uses any reported sizes or offsets.

Add a shared validator in debug_offsets_validation.h and run it once when
_Py_DebugOffsets is loaded and once when AsyncioDebug is loaded. The checks
cover section sizes used for fixed local buffers and every offset that is
later dereferenced against a local buffer or local object view. This keeps
the bounds checks out of the sampling hot path while rejecting malformed
tables up front.

5 days agogh-144881: Add retry logic to asyncio debugging tools (#148530)
Bartosz Sławecki [Mon, 13 Apr 2026 22:10:54 +0000 (00:10 +0200)] 
gh-144881: Add retry logic to asyncio debugging tools (#148530)

Transient errors can occur when attaching to a process that is actively
using thread delegation (e.g. asyncio.to_thread). Add a retry loop to
_get_awaited_by_tasks for RuntimeError, OSError, UnicodeDecodeError, and
MemoryError, and expose --retries CLI flag on both `ps` and `pstree`
subcommands (default: 3).

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
5 days agogh-146445: Migrate Android build tools to the Platforms folder. (#148282)
Russell Keith-Magee [Mon, 13 Apr 2026 21:41:16 +0000 (05:41 +0800)] 
gh-146445: Migrate Android build tools to the Platforms folder. (#148282)

Migrates Android build tooling to the shared Platforms folder.

Co-authored-by: Malcolm Smith <smith@chaquo.com>
5 days agogh-146139: Disable `socketpair` authentication on WASI (#146140)
Joel Dice [Mon, 13 Apr 2026 21:06:36 +0000 (15:06 -0600)] 
gh-146139: Disable `socketpair` authentication on WASI (#146140)

Calling `connect(2)` on a non-blocking socket on WASI may leave the socket in a
"connecting" but not yet "connected" state.  In the former case, calling
`getpeername(2)` on it will fail, leading to an unhandled exception in Python.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
6 days agogh-148169: Fix webbrowser `%action` substitution bypass of dash-prefix check (#148170)
Stan Ulbrych [Mon, 13 Apr 2026 19:02:52 +0000 (20:02 +0100)] 
gh-148169: Fix webbrowser `%action` substitution bypass of dash-prefix check (#148170)

6 days agoFix "encodings" typo in argparse.FileType documentation (#148502)
Gleb Popov [Mon, 13 Apr 2026 18:12:25 +0000 (21:12 +0300)] 
Fix "encodings" typo in argparse.FileType documentation (#148502)

6 days agogh-148393: Use acquire load for _ma_watcher_tag in dict notify event (gh-148509)
Sam Gross [Mon, 13 Apr 2026 18:11:28 +0000 (14:11 -0400)] 
gh-148393: Use acquire load for _ma_watcher_tag in dict notify event (gh-148509)

The watcher-bits read in _PyDict_NotifyEvent needs to use acquire to
synchronize with the release from PyDict_Watch so that the callback
publication is visible before the callback is invoked.

6 days agoMinor improvement to statistics.pdf() (gh-148500)
Raymond Hettinger [Mon, 13 Apr 2026 16:29:15 +0000 (11:29 -0500)] 
Minor improvement to statistics.pdf() (gh-148500)

6 days agogh-131798: JIT: Optimize `_CHECK_IS_NOT_PY_CALLABLE_EX` and `_CHECK_IS_NOT_PY_CALLABL...
Wulian233 [Mon, 13 Apr 2026 14:41:06 +0000 (22:41 +0800)] 
gh-131798: JIT: Optimize `_CHECK_IS_NOT_PY_CALLABLE_EX` and `_CHECK_IS_NOT_PY_CALLABLE_KW` (GH-148494)

6 days agogh-131798: optimize through keyword and bound method calls in the JIT (GH-148466)
Kumar Aditya [Mon, 13 Apr 2026 13:14:48 +0000 (18:44 +0530)] 
gh-131798: optimize through keyword and bound method calls in the JIT (GH-148466)

Co-authored-by: Ken Jin <kenjin4096@gmail.com>
6 days agogh-148483: Use Py_GCC_ATTRIBUTE(unused) for stop_tracing label (GH-148481)
Charlie Lin [Mon, 13 Apr 2026 13:05:34 +0000 (09:05 -0400)] 
gh-148483: Use Py_GCC_ATTRIBUTE(unused) for stop_tracing label (GH-148481)

6 days agogh-148285: Allow recording uops after specializing uops (GH-148482)
Neko Asakura [Mon, 13 Apr 2026 12:56:29 +0000 (08:56 -0400)] 
gh-148285: Allow recording uops after specializing uops (GH-148482)

6 days agogh-96894: Do not turn echo off for subsequent commands in batch activators (GH-96895)
Paweł Szramowski [Mon, 13 Apr 2026 11:50:46 +0000 (13:50 +0200)] 
gh-96894: Do not turn echo off for subsequent commands in batch activators (GH-96895)

6 days agoInternalDocs: Correct struct path for latin1 singletons in `string_interning.md`...
Stan Ulbrych [Mon, 13 Apr 2026 09:45:41 +0000 (10:45 +0100)] 
InternalDocs: Correct struct path for latin1 singletons in `string_interning.md` (GH-148358)

6 days agogh-148395: Fix a possible UAF in `{LZMA,BZ2,_Zlib}Decompressor` (GH-148396)
Stan Ulbrych [Mon, 13 Apr 2026 01:14:54 +0000 (02:14 +0100)] 
gh-148395: Fix a possible UAF in `{LZMA,BZ2,_Zlib}Decompressor` (GH-148396)

Fix dangling input pointer after `MemoryError` in _lzma/_bz2/_ZlibDecompressor.decompress

6 days agogh-121190: Emit a better error message from `importlib.resources.files()` when module...
Jason R. Coombs [Sun, 12 Apr 2026 22:15:01 +0000 (18:15 -0400)] 
gh-121190: Emit a better error message from `importlib.resources.files()` when module spec is `None`" (#148460)

Also merges incidental changes from importlib_resources 7.1.

Co-authored by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>

6 days agogh-146450: Ensure Android gradle build uses custom cross-build dir (#148319)
Russell Keith-Magee [Sun, 12 Apr 2026 21:57:29 +0000 (05:57 +0800)] 
gh-146450: Ensure Android gradle build uses custom cross-build dir (#148319)

Ensures that the testbed's Gradle configuration uses the cross-build environment
variable, and that variable is passed to Gradle by the cross-build script.

Co-authored-by: Malcolm Smith <smith@chaquo.com>
6 days agogh-105936: Properly update closure cells for `__setattr__` and `__delattr__` in froze...
Sviataslau [Sun, 12 Apr 2026 21:12:19 +0000 (00:12 +0300)] 
gh-105936: Properly update closure cells for `__setattr__` and `__delattr__` in frozen dataclasses with slots (GH-144021)

7 days agogh-148438: implement `_RECORD_BOUND_METHOD` in JIT (GH-148457)
Neko Asakura [Sun, 12 Apr 2026 18:57:55 +0000 (14:57 -0400)] 
gh-148438: implement `_RECORD_BOUND_METHOD` in JIT (GH-148457)

7 days agogh-131798: Split `_CHECK_AND_ALLOCATE_OBJECT` into smaller uops (GH-148433)
Sacul [Sun, 12 Apr 2026 18:31:24 +0000 (02:31 +0800)] 
gh-131798: Split `_CHECK_AND_ALLOCATE_OBJECT` into smaller uops (GH-148433)

Co-authored-by: Hai Zhu <haiizhu@outlook.com>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
7 days agogh-146261: JIT: protect against function version changes (#146300)
Ken Jin [Sun, 12 Apr 2026 18:23:47 +0000 (02:23 +0800)] 
gh-146261: JIT: protect against function version changes (#146300)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
7 days agogh-139551: add support for BaseExceptionGroup in IDLE (GH-139563)
Locked-chess-official [Sun, 12 Apr 2026 17:06:41 +0000 (01:06 +0800)] 
gh-139551: add support for BaseExceptionGroup in IDLE (GH-139563)

Meaningfully render ExceptionGroup tracebacks in the IDLE GUI REPL.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
7 days agogh-148393: Use atomic ops on _ma_watcher_tag in free threading build (gh-148397)
Sam Gross [Sun, 12 Apr 2026 14:40:41 +0000 (10:40 -0400)] 
gh-148393: Use atomic ops on _ma_watcher_tag in free threading build (gh-148397)

Fixes data races between dict mutation and watch/unwatch on the same dict.

7 days agogh-131798: Add `_CHECK_IS_NOT_PY_CALLABLE` to the JIT optimizer (GH-148434)
Wulian233 [Sun, 12 Apr 2026 13:07:19 +0000 (21:07 +0800)] 
gh-131798: Add `_CHECK_IS_NOT_PY_CALLABLE` to the JIT optimizer (GH-148434)

7 days agogh-148398: add type watcher in `_CHECK_ATTR_CLASS` (GH-148399)
Neko Asakura [Sun, 12 Apr 2026 12:54:03 +0000 (08:54 -0400)] 
gh-148398: add type watcher in `_CHECK_ATTR_CLASS` (GH-148399)

7 days agogh-146313: Fix multiprocessing ResourceTracker deadlock after os.fork() (GH-146316)
Gregory P. Smith [Sun, 12 Apr 2026 06:06:19 +0000 (23:06 -0700)] 
gh-146313: Fix multiprocessing ResourceTracker deadlock after os.fork() (GH-146316)

`ResourceTracker.__del__` (added in gh-88887 circa Python 3.12) calls
os.waitpid(pid, 0) which blocks indefinitely if a process created via os.fork()
still holds the tracker pipe's write end. The tracker never sees EOF, never
exits, and the parent hangs at interpreter shutdown.

Fix with two layers:

- **At-fork handler.** An os.register_at_fork(after_in_child=...)
  handler closes the inherited pipe fd in the child unless a preserve
  flag is set. popen_fork.Popen._launch() sets the flag before its
  fork so mp.Process(fork) children keep the fd and reuse the parent's
  tracker (preserving gh-80849). Raw os.fork() children close the fd,
  letting the parent reap promptly.

- **Timeout safety-net.** _stop_locked() gains a wait_timeout
  parameter. When called from `__del__`, it polls with WNOHANG using
  exponential backoff for up to 1 second instead of blocking
  indefinitely. The at-fork handler makes this unreachable in
  well-behaved paths; it remains for abnormal shutdowns.

Co-authored-by: Itamar Oren <itamarost@gmail.com>
7 days agoGH-148047: Check early whether tail-calling is possible for MSVC builds on Windows...
Chris Eibl [Sun, 12 Apr 2026 05:49:18 +0000 (07:49 +0200)] 
GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows (#148036)

Rather than failing late when compiling e.g. a debug configuration
```
build.bat -c debug --tail-call-interp
```
with hundreds of
```
error C4737: Unable to perform required tail call. Performance may be degraded.
```
-- fail early with an explicit error message for configurations that are not supported by MSVC.

This is a follow-up on https://github.com/python/cpython/issues/140513 / https://github.com/python/cpython/pull/140548

7 days agogh-89520: Load extension settings and keybindings from user config (GH-28713)
CoolCat467 [Sun, 12 Apr 2026 04:44:33 +0000 (23:44 -0500)] 
gh-89520: Load extension settings and keybindings from user config (GH-28713)

Extension keybindings defined in ~/.idlerc/config-extensions.cfg were silently ignored because GetExtensionKeys, __GetRawExtensionKeys, and GetExtensionBindings only checked default config. Fix these to check user config as well, and update the extensions config dialog to handle user-only extensions correctly.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
7 days agogh-100305: Deemphasize that `ast.literal_eval` is safe in `eval` documentation (...
Ram Vikram Singh [Sun, 12 Apr 2026 03:07:42 +0000 (08:37 +0530)] 
gh-100305: Deemphasize that `ast.literal_eval` is safe in `eval` documentation (#100326)

Co-authored-by: Éric <merwok@netwok.org>
7 days agogh-147965: Add shutdown() to multiprocessing.Queue excluded methods (GH-147970)
WYSIATI [Sun, 12 Apr 2026 00:46:06 +0000 (08:46 +0800)] 
gh-147965: Add shutdown() to multiprocessing.Queue excluded methods (GH-147970)

The multiprocessing.Queue documentation states it implements all
methods of queue.Queue except task_done() and join(). Since
queue.Queue.shutdown() was added in Python 3.13,
multiprocessing.Queue also does not implement it. Update the docs
to include shutdown() in the list of excluded methods.

7 days agogh-97032: avoid test_squeezer crash on macOS buildbots (gh-115508) (GH-148141)
Neil Schemenauer [Sun, 12 Apr 2026 00:43:04 +0000 (17:43 -0700)] 
gh-97032: avoid test_squeezer crash on macOS buildbots (gh-115508) (GH-148141)

gh-97032: avoid test_squeezer crash on macOS buildbots (#115508)

avoid test_squeezer crash on macOS buildbots

Co-authored-by: Ned Deily <nad@python.org>
7 days agogh-148208: Fix recursion depth leak in `PyObject_Print` (GH-148209)
Wulian233 [Sun, 12 Apr 2026 00:26:18 +0000 (08:26 +0800)] 
gh-148208: Fix recursion depth leak in `PyObject_Print` (GH-148209)

7 days agogh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851)
Shamil [Sun, 12 Apr 2026 00:14:50 +0000 (03:14 +0300)] 
gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851)

Hold strong references to borrowed items unconditionally (not only in
free-threading builds) in _encoder_iterate_mapping_lock_held and
_encoder_iterate_fast_seq_lock_held.  User callbacks invoked during
encoding can mutate or clear the underlying container, invalidating
borrowed references.

The dict iteration path was already fixed by gh-145244.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
7 days agogh-146287: Fix signed/unsigned mismatch in _hashlib_hmac_digest_size (GH-148407)
Gregory P. Smith [Sun, 12 Apr 2026 00:02:56 +0000 (17:02 -0700)] 
gh-146287: Fix signed/unsigned mismatch in _hashlib_hmac_digest_size (GH-148407)

* gh-146287: use signed type for HMAC digest size to prevent unsigned wrapping

Change _hashlib_hmac_digest_size() return type from unsigned int to int
so that a hypothetical negative return from EVP_MD_size() is not
silently wrapped to a large positive value. Add an explicit check for
negative digest_size in the legacy OpenSSL path, and use SystemError
(not ValueError) since these conditions indicate internal invariant
violations. Also add debug-build asserts to EVP_get_block_size and
EVP_get_digest_size documenting that the hash context is always
initialized.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
7 days agotests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345)
Artem Yarulin [Sun, 12 Apr 2026 00:01:18 +0000 (03:01 +0300)] 
tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345)

test_interpreters: use errno.EBADF instead of hardcoded number in _close_file()

Replace the hardcoded `9` check in `Lib/test/test_interpreters/utils.py` with `errno.EBADF`.

Using `errno.EBADF` makes the helper portable across platforms with different errno numbering while preserving the intended behavior.

7 days agogh-145244: Fix use-after-free on borrowed dict key in json encoder (GH-145245)
Ramin Farajpour Cami [Sat, 11 Apr 2026 22:26:36 +0000 (01:56 +0330)] 
gh-145244: Fix use-after-free on borrowed dict key in json encoder (GH-145245)

In encoder_encode_key_value(), key is a borrowed reference from
PyDict_Next(). If the default callback mutates or clears the dict,
key becomes a dangling pointer. The error path then calls
_PyErr_FormatNote("%R", key) on freed memory.

Fix by holding strong references to key and value unconditionally
during encoding, not just in the free-threading build.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
7 days agogh-127012: `Traversable.read_text` now allows/solicits an `errors` parameter. (#148401)
Jason R. Coombs [Sat, 11 Apr 2026 22:25:20 +0000 (18:25 -0400)] 
gh-127012: `Traversable.read_text` now allows/solicits an `errors` parameter. (#148401)

Applies changes from importlib_resources 6.5.2.

7 days agogh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)
Ramin Farajpour Cami [Sat, 11 Apr 2026 22:18:02 +0000 (01:48 +0330)] 
gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)

When a custom iterator calls next() on the same csv.reader from
within __next__, the inner iteration sets self->fields to NULL.
The outer iteration then crashes in parse_save_field() by passing
NULL to PyList_Append.

Add a guard after PyIter_Next() to detect that fields was set to
NULL by a re-entrant call, and raise csv.Error instead of crashing.

7 days agogh-145200: Fix EVP_MAC_CTX leak in hashlib HMAC on init failure (GH-145201)
Ramin Farajpour Cami [Sat, 11 Apr 2026 22:10:43 +0000 (01:40 +0330)] 
gh-145200: Fix EVP_MAC_CTX leak in hashlib HMAC on init failure (GH-145201)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
7 days agogh-146302: make Py_IsInitialized() thread-safe and reflect true init completion ...
Gregory P. Smith [Sat, 11 Apr 2026 21:54:23 +0000 (14:54 -0700)] 
gh-146302: make Py_IsInitialized() thread-safe and reflect true init completion (GH-146303)

## Summary

- Move the `runtime->initialized = 1` store from before `site.py` import to the end of `init_interp_main()`, so `Py_IsInitialized()` only returns true after initialization has fully completed
- Access `initialized` and `core_initialized` through new inline accessors using acquire/release atomics, to also protect from data race undefined behavior
- `PySys_AddAuditHook()` now uses the accessor, so with the flag move it correctly skips audit hook invocation during all init phases (matching the documented "after runtime initialization" behavior) ... We could argue that running these earlier would be good even if the intent was never explicitly expressed, but that'd be its own issue.

## Motivation

`Py_IsInitialized()` returned 1 while `Py_InitializeEx()` was still running — specifically, before `site.py` had been imported. See https://github.com/PyO3/pyo3/issues/5900 where a second thread could acquire the GIL and start executing Python with an incomplete `sys.path` because `site.py` hadn't finished.

The flag was also a plain `int` with no atomic operations, making concurrent reads a C-standard data race, though unlikely to manifest.

## Regression test:

The added test properly fails on `main` with `ERROR: Py_IsInitialized() was true during site import`.

---

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>