Commit graph

56942 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
Hai Zhu
618b726d68
gh-146073: Add fitness/exit quality mechanism for JIT trace frontend (GH-148089)
* Replaces ad-hoc logic for ending traces with a simple inequality: `fitness < exit_quality`
* Fitness starts high and is reduced for branches, backward edges, calls and trace length
* Exit quality reflect how good a spot that instruction is to end a trace. Closing a loop is very, specializable instructions are very low and the others in between.
2026-04-24 10:37:01 +01: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
Raymond Hettinger
fbc7676df6
Speed up counting in statistics.fmean() (gh-148875) 2026-04-22 22:06:56 -05: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
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
Filipe Laíns
513db72110
GH-145278: also filter mmap2 in strace_helper.filter_memory (GH-148648)
Signed-off-by: Filipe Laíns <lains@riseup.net>
2026-04-20 15:41:10 +02: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
Daniel Hollas
4b33308137
gh-148406: Fix annotations of _colorize.FancyCompleter (#148408)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-18 21:51:58 +03:00
Serhiy Storchaka
7ce737ea11
gh-148653: Fix reference leaks in test_marshal introduced in gh-148698 (GH-148725) 2026-04-18 12:11:14 +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
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
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
Mark Shannon
600f4dbd54
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
2026-04-16 15:22:22 +01:00
Pieter Eendebak
1f6a09fb36
gh-100239: Specialize more binary operations using BINARY_OP_EXTEND (GH-128956) 2026-04-16 09:22:41 +01:00
Jelle Zijlstra
5b8cd314e2
gh-137814: Fix __qualname__ of __annotate__ (#137842) 2026-04-15 21:52:30 -07:00
Neko Asakura
e998eb9a83
gh-148604: change ADD_OP(_POP_TOP, ...) to optimize_pop_top in optimizer_bytecodes.c (GH-148619) 2026-04-16 01:08:29 +08:00
Victor Stinner
70eb56be42
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.
2026-04-15 15:59:02 +02: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
Gregory P. Smith
fd81246bd5
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
2026-04-14 23:31:58 +00:00
Pieter Eendebak
5c3decad66
gh-146393: Use recorded type instead of instance in BINARY_OP (#148569) 2026-04-14 20:11:42 +00: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
Kumar Aditya
3cb7eaec85
gh-131798: constant fold special method lookups in JIT (#148432) 2026-04-14 16:02:23 +00:00
Kumar Aditya
1aa7e7ee6d
gh-gh-131798: optimize LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN in the JIT (#148555) 2026-04-14 21:00:32 +05:30
Wulian233
e0b56f006c
gh-131798: Constant-fold _CONTAINS_OP_DICT for frozendict (GH-148548) 2026-04-14 23:04:28 +08:00
Neko Asakura
52a7f1b7f8
gh-148510: restore func_version check in _LOAD_ATTR_PROPERTY_FRAME (GH-148528) 2026-04-14 22:44:39 +08: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
Hai Zhu
5ce0fe8b6c
gh-148378: Allow multiple consecutive recording ops per macro op (GH-148496) 2026-04-14 19:26:53 +08:00
Bartosz Sławecki
21da9d7164
gh-143955: Prevent schema drift false-positives in asyncio tools tests (#148525) 2026-04-14 10:29:01 +01:00
Stan Ulbrych
44f1b987ed
gh-148487: Fix issues in test_add_python_opts (#148507) 2026-04-14 07:45:26 +01:00
Neko Asakura
e02ac1d907
gh-148515: make optimizer_generator respect multiple caches (#148524) 2026-04-14 12:51:05 +08:00