Commit graph

32550 commits

Author SHA1 Message Date
John Belmonte
95559d2a7e
gh-108951: add TaskGroup.cancel() (#127214)
Fixes #108951

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Co-authored-by: Guido van Rossum <guido@python.org>
2026-04-24 11:22:05 -07:00
Bartosz Sławecki
448d7b96c1
gh-145239: Accept unary plus literal pattern (#148566)
Add '+' alternatives to signed_number and signed_real_number grammar
rules, mirroring how unary minus is already handled for pattern matching.
Unary plus is a no-op on numbers so the value is returned directly without
wrapping in a UnaryOp node.
2026-04-23 22:07:28 +03:00
Sam Gross
4629c2215a
gh-113956: Make intern_common thread-safe in free-threaded build (gh-148886)
Avoid racing with the owning thread's refcount operations when
immortalizing an interned string: if we don't own it and its refcount
isn't merged, intern a copy we own instead. Use atomic stores in
_Py_SetImmortalUntracked so concurrent atomic reads are race-free.
2026-04-23 14:42:57 -04:00
Hugo van Kemenade
42d645a7e8
gh-132631: Fix "I/O operation on closed file" when parsing JSON Lines file (#132632)
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2026-04-23 15:27:02 +00:00
Eoin Shaughnessy
435be06dd2
gh-148663: Document that calendar.IllegalMonthError inherits from both ValueError and IndexError (#148664)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-23 15:50:23 +01:00
Stan Ulbrych
0469e6d38d
gh-148735: Fix a UAF in Element.findtext() (#148738) 2026-04-23 15:48:00 +01:00
David Ellis
158dbbb97f
gh-148680: Replace internal names with type_reprs of objects in string representations of ForwardRef (#148682)
Co-authored-by: Shamil <ashm.tech@proton.me>
2026-04-23 06:22:20 -07:00
Petr Viktorin
ab41a347eb
gh-146636: Improve ABI/feature selection, add new header for it (GH-148302)
Improve ABI/feature selection, add new header for it.

Add a test that Python headers themselves don't use
Py_GIL_DISABLED in abi3t: abi3 and abi3t ought to be the
same except the _Py_OPAQUE_PYOBJECT differences.
This is done using the GCC-only poison pragma.

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-23 11:52:13 +02:00
Pieter Eendebak
8e43f3d117
gh-145056: Add support for frozendict in dataclass asdict and astuple (#145125) 2026-04-22 19:39:08 -07:00
Shamil
be833e658a
gh-146553: Fix infinite loop in typing.get_type_hints() on circular __wrapped__ (#148595) 2026-04-22 19:31:58 -07:00
Seth Larson
76b3923d68
gh-90309: Base64-encode cookie values embedded in JS 2026-04-22 19:22:31 +00:00
Sam Gross
ad3c5b7958
gh-148820: Fix _PyRawMutex use-after-free on spurious semaphore wakeup (gh-148852)
_PyRawMutex_UnlockSlow CAS-removes the waiter from the list and then
calls _PySemaphore_Wakeup, with no handshake. If _PySemaphore_Wait
returns Py_PARK_INTR, the waiter can destroy its stack-allocated
semaphore before the unlocker's Wakeup runs, causing a fatal error from
ReleaseSemaphore / sem_post.

Loop in _PyRawMutex_LockSlow until _PySemaphore_Wait returns Py_PARK_OK,
which is only signalled when a matching Wakeup has been observed.

Also include GetLastError() and the handle in the Windows fatal messages
in _PySemaphore_Init, _PySemaphore_Wait, and _PySemaphore_Wakeup to make
similar races easier to diagnose in the future.
2026-04-22 14:31:19 -04:00
KotlinIsland
04fd103713
gh-148207: add additional keywords to typing.TypeVarTuple (#148212) 2026-04-22 06:28:12 -07:00
Gabriele N. Tornetta
858e69eab0
gh-142186: Allow all PEP-669 events to be per-code object and disableable (GH-146182)
* Make the `PY_UNWIND` monitoring event available as a code-local
event to allow trapping on function exit events when an exception
bubbles up. This complements the PY_RETURN event by allowing to
catch any function exit event.

* Allow `PY_UNWIND`  to be `DISABLE`d; disabling it disables the event for the whole code object.

* Do the above for `PY_THROW`, `RAISE`, `EXCEPTION_HANDLED`, and `RERAISE` events.
2026-04-22 09:08:23 +01:00
Stan Ulbrych
33e82be174
gh-148801: Fix unbound C recursion in Element.__deepcopy__() (#148802) 2026-04-21 17:20:18 +01:00
Seth Larson
1274766d3c
gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (#148809) 2026-04-21 07:29:07 -07:00
Roman Donchenko
f6ed7c0acb
gh-108411: Make typing.IO/BinaryIO arguments positional-only (#142906)
`IO` is purported to be the type of the file objects returned by `open`.
However, all methods on those objects take positional-only arguments, while
`IO`'s methods are declared with regular arguments. As such, the file objects
cannot actually be considered to implement `IO`. The same thing applies to
`BinaryIO`.

Fix this by adjusting the definition of these ABCs to match the file objects.

This is technically a breaking change, but it is unlikely to actually break
anything:

* These methods should never be called at runtime, since they are abstract.
  Therefore, this should not cause any runtime errors.

* In typeshed these arguments are already positional-only, so this should
  not cause any errors during typechecking either.
2026-04-20 13:19:43 -07:00
Uwe L. Korn
5a3f479601
gh-138451: Support custom LLVM installation path (#138452)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-04-20 16:45:53 +00:00
Régis Desgroppes
5c5dae0282
gh-148644: Propagate the PGO job exit code in PCbuild/build.bat (GH-148645) 2026-04-20 15:18:10 +01:00
Serhiy Storchaka
bfe6f9f590
gh-123853: Update locale.windows_locale (GH-123901)
Update the table of Windows language code identifiers (LCIDs) to
protocol version 16.0 (2024-04-23).
2026-04-20 11:47:37 +03:00
Hugo van Kemenade
9e23652230
Prevent GitHub's web conflict editor from converting LF to CRLF (#148739) 2026-04-19 12:21:17 +03:00
Victor Stinner
d61fcf834d
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.
2026-04-18 09:56:56 +00:00
Serhiy Storchaka
2e37d83641
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.
2026-04-18 11:24:33 +03:00
Jelle Zijlstra
92164dc917
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>
2026-04-17 19:20:41 -07:00
Prakash Sellathurai
634568d030
gh-148222: Fix NULL dereference bugs in genericaliasobject.c (#148226) 2026-04-17 17:21:13 -07:00
Michael Bommarito
446edda209
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.
2026-04-17 08:42:41 -07:00
Sergey B Kirpichev
769cc8338f
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>
2026-04-17 14:09:09 +02:00
Victor Stinner
2faceeec5c
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.
2026-04-16 19:13:25 +02:00
Dino Viehland
c0af5c024b
gh-146031: Allow keeping specialization enabled when specifying eval frame function (#146032)
Allow keeping specialization enabled when specifying eval frame function
2026-04-16 09:44:26 -07:00
Petr Viktorin
0fcf2b72d3
gh-146636: PEP 803: Reference documentation (GH-148013)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-16 14:17:44 +02:00
Pieter Eendebak
1f6a09fb36
gh-100239: Specialize more binary operations using BINARY_OP_EXTEND (GH-128956) 2026-04-16 09:22:41 +01:00
Joshua Root
5f28e6b818
gh-148474: Fix _Py_hexlify_simd compilation with older clang (#148475) 2026-04-16 11:21:23 +05:30
Jelle Zijlstra
5b8cd314e2
gh-137814: Fix __qualname__ of __annotate__ (#137842) 2026-04-15 21:52:30 -07:00
Hugo van Kemenade
eb2f634b83
gh-148100: Soft deprecate re.match and re.Pattern.match in favour of prefixmatch (#148101) 2026-04-15 23:09:47 +03:00
Carey Metcalfe
cb339d3c9e
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.
2026-04-15 06:24:28 -07:00
Michiel W. Beijen
ca064d9b99
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.
2026-04-15 14:21:43 +02:00
Bénédikt Tran
69e0a78e6e
gh-148390: fix undefined behavior of memoryview(...).cast("?") (#148454) 2026-04-15 11:42:20 +00:00
Anerdw
d14e31ed68
gh-147957: pop items from UserDict in LIFO order (gh-147958) 2026-04-14 23:29:41 -05:00
Stan Ulbrych
d0e7c6acc9
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
2026-04-14 17:15:27 -07:00
Filipe Laíns
0012686d92
GH-145278: freeze encodings (partially) and linecache (#148347) 2026-04-14 21:01:23 +01:00
Pieter Eendebak
95cbd4a232
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>
2026-04-15 02:08:04 +08:00
Bénédikt Tran
356a031de5
gh-146563: add exception note for invalid Expat handler return values (#146565) 2026-04-14 19:12:47 +02:00
Ken Jin
11da7d4e21
gh-148047: Revert "GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows (#148036)" (#148558)
This reverts commit cbd81d59cf.
2026-04-14 23:46:54 +08:00
Geoffrey Thomas
c88c27b0c1
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.
2026-04-14 16:26:19 +01:00
Henry Jones
4af46b4ab5
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.
2026-04-14 09:10:08 -04:00
Loïc Simon
74a4f8c1d0
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>
2026-04-14 14:37:41 +03:00
Neko Asakura
e02ac1d907
gh-148515: make optimizer_generator respect multiple caches (#148524) 2026-04-14 12:51:05 +08:00
Russell Keith-Magee
c40e8b016a
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.
2026-04-14 11:12:37 +08:00
Pablo Galindo Salgado
eb4c78df07
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.
2026-04-13 23:43:55 +01:00
Bénédikt Tran
2662db0c45
gh-148370: prevent quadratic behavior in configparser.ParsingError.combine (#148452) 2026-04-14 00:32:54 +02:00