Commit graph

32603 commits

Author SHA1 Message Date
dr-carlos
c1940bcfc8
gh-141388: Improve docs/tests for non-function callables as annotate functions (#142327) 2026-05-02 18:21:59 -07:00
Eric Mark Martin
a65611e7f5
gh-149171: Make TypeAliasType __module__ writable (#149172)
closes #149171.
2026-05-02 17:28:08 +00:00
Brian Schubert
bdedc4a20e
gh-116021: Deprecate support for instantiating abstract AST nodes (#137865)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-02 09:50:06 -07:00
Sergey Miryanov
39f123c587
GH-146527: Add get_gc_stats function to _remote_debugging (#148071) 2026-05-02 15:04:18 +00:00
Pablo Galindo Salgado
efcac6f281
gh-149214: Fix non ascii characters in remote debugging (#149228) 2026-05-02 15:07:28 +01:00
Diego Russo
c7b7ca2cd5
GH-126910: Add gdb support for unwinding JIT frames (#146071)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-05-02 13:42:03 +00:00
lighting9999
4f0cfe53cb
gh-149221:Fix binomialvariate Function for random module (gh-149222) 2026-05-02 07:55:43 -05:00
Serhiy Storchaka
b89735625d
gh-148914: Fix memoization of in-band PickleBuffer in the Python implementation (GH-149052)
Previously, identical PickleBuffers did not preserve identity.
Also, empty writable PickleBuffer memoized an empty bytearray object
in place of b'' which is a singleton in CPython, so the following
references to b'' were unpickled as an empty bytearray object.
2026-05-02 12:04:05 +03:00
Russell Keith-Magee
e635ad2c68
gh-149254: Bump OpenSSL versions for iOS and Android. (#149270)
Bump OpenSSL versions for iOS and Android.
2026-05-02 16:50:32 +08:00
Ned Deily
0e2c055892
gh-149254: Update macOS installer to use OpenSSL 3.5.6. (#149262) 2026-05-01 23:52:43 -04:00
W. H. Wang
ff35fe4633
gh-149117: Set ImportError.name on errors from runpy.run_module/run_path (gh-149159)
Set ImportError.name on errors from runpy.run_module/run_path

`runpy.run_module()` and `runpy.run_path()` now set the `name` attribute
of the `ImportError` they raise to the requested module name, matching
the behaviour of a regular import statement (previously `name` was
always `None`, which broke introspection).

The `name=` kwarg is gated on `issubclass(error, ImportError)` because
`_get_module_details()` is also used by `_run_module_as_main()` with
a private `_Error` sentinel class. `_Error` does not subclass
ImportError, and `BaseException.__init__` rejects unknown kwargs at
the C level, so passing `name=` unconditionally would break the
`python -m foo` codepath.
2026-05-02 12:27:23 +10:00
Brett Cannon
be9c7cb4b5
GH-149252: Update WASI SDK version from 32 to 33 (#149253)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-05-01 16:51:06 -07:00
Amp Tell
bb911a2319
gh-75707: tarfile: Add optional open() argument "mtime" (GH-138117)
This makes it possible to set the gzip header mtime field without
overriding time.time(), making it useful when creating reproducible
archives.

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2026-05-01 15:39:58 -07:00
Raymond Hettinger
91e871a307
gh-124397: Add free-threading support for iterators. (gh-148894) 2026-05-01 16:31:00 -05:00
Pablo Galindo Salgado
3236773257
gh-149202: Implement PEP 831 – Frame Pointers Everywhere: Enabling System-Level Observability for Python (#149201)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2026-05-01 21:16:11 +01:00
Mike Edmunds
b605573828
gh-81074: Allow non-ASCII addr_spec in email.headerregistry.Address (#122477)
The email.headerregistry.Address constructor raised an error if
addr_spec contained a non-ASCII character. (But it fully supports
non-ASCII in the separate username and domain args.) This change
removes the error for a non-ASCII addr_spec, as well as the
Defect that triggered it.  In the unicode era non-ascii is not a
defect, though it is an error when an attempt is made to serialize
it to ascii.  The serialization issue was handled in #122540.
2026-05-01 14:00:46 -04:00
Mike Edmunds
d96ffc1832
gh-83938, gh-122476: Stop incorrectly RFC 2047 encoding non-ASCII email addresses (#122540)
The email generators had been incorrectly flattening non-ASCII email
addresses to RFC 2047 encoded-word format, leaving them undeliverable.
(RFC 2047 prohibits use of encoded-word in an addr-spec.)
This change raises a HeaderWriteError when attempting to flatten an
EmailMessage with a non-ASCII addr-spec and a policy with utf8=False.
(Exception: If the non-ASCII address originated from parsing a message,
it will be flattened as originally parsed, without error.)  This also applies
to other contexts in which RFC2047 words are not allowed by the RFCs.

Non-ASCII email addresses are supported when using a policy with
utf8=True (such as email.policy.SMTPUTF8) under RFCs 6531 and 6532.

Non-ASCII email address domains (but not localparts) can also be used
with non-SMTPUTF8 policies by encoding the domain as an IDNA A-label.
(The email package does not perform this encoding, because it cannot
know whether the caller wants IDNA 2003, IDNA 2008, or some other
variant such as UTS #46.)

Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2026-05-01 13:52:06 -04:00
petervanvugt
9668d260a1
gh-148850: Fix memory sanitizer false positive in os.getrandom (GH-148851)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-05-01 17:37:36 +02:00
Tan Long
8066db5753
gh-149173: Fix inverted PYTHON_BASIC_REPL environment check in _pyrepl_available() (#149174) 2026-04-30 22:32:57 -07:00
Savannah Ostrowski
c0e0640039
GH-146475: Block Apple Clang for building JIT stencils (#149188) 2026-04-30 22:09:36 +00:00
R. David Murray
bdbb55c403
gh-148518 fix index error in local part attribute (#148522)
As part of fixing bpo-27931 code was introduced to get_bare_quoted_string
that added an empty Terminal if the quoted string was empty.  This isn't
the best answer in terms of the parse tree; we really want the token
list to be empty in that case.  But having it be empty resulted in
local_part raising the index error.  We find that same problem if we
try to parse an address consisting of a single dquote.  By fixing
local_part to not raise on an empty token list, we can have the
bare_quoted_string code correctly return an empty token list for
the empty string cases (two dquotes or a single dquote as the
entire addrespec, at the end of a line).
2026-04-30 17:41:43 -04:00
Sergey Miryanov
1575a81bf2
GH-148726: Forward-port generational GC. (GH-148746)
The replaces the incremental GC with a forward port (from 3.13) of the generational GC.

Co-Authored-By: Neil Schemenauer <nas@arctrix.com>
Co-Authored-By: Zanie Blue <contact@zanie.dev>
Co-Authored-By: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-30 12:19:13 -07:00
elenril
b413bc7a1f
bpo-39100: _header_value_parser: do not treat a Group as invalid-mailbox (#24872)
When an address in an address-list has garbage at the end, the code will
currently:

1. change the mailbox in the last parsed address into invalid-mailbox by
   overriding its token_type;
2. wrap the trailing garbage into another invalid-mailbox and append it
   to the last parsed address.

However, that does not take into account that an address may
also contain a Group instead of a single mailbox. In that case,
overwriting token_type leads to undesirable results, e.g. parsing an
email with the following 'To' header:

unlisted-recipients:; (no To-header on input)

raises an AttributeError from trying to treat the Group as a Mailbox.

Moreover it is questionable whether the previously parsed mailbox should
be treated as invalid in addition to the trailing garbage.

Address both of the above by wrapping the trailing garbage in a new
Address with a single invalid-mailbox, and append it to the AddressList
directly.

Changes the results of the
test_get_address_list_mailboxes_invalid_addresses test, where the
address list is now parsed into 4 mailboxes instead of 3 (all but the
first one are invalid).
2026-04-30 13:24:23 -04:00
Victor Stinner
a60520da3c
gh-147991: Speed up tomllib import time (GH-147992)
- Use lazy import for regular expressions.
- Use frozendict for string escapes

Co-authored-by: Taneli Hukkinen <hukkinen@eurecom.fr>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-04-30 18:25:32 +02:00
John Comeau
cc5f8b5434
gh-113471: Add custom default Content-Type to http.server (#113475)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: donBarbos <donbarbos@proton.me>
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-30 18:00:48 +03:00
Eric Froemling
7686abe063
gh-149085: Add max_threads keyword to faulthandler.dump_traceback() (GH-149106)
Add a keyword-only `max_threads` argument to `dump_traceback()` and
`dump_traceback_later()`, defaulting to 100 to preserve existing
behavior. Allows server processes with many worker threads to dump
beyond the historical 100-thread cap (previously a hardcoded
`MAX_NTHREADS = 100` in `Python/traceback.c`).

The cap matters in practice: tstates are prepended to the
PyInterpreterState linked list, so the dump walks newest-first. With
more than 100 threads alive, the main thread (oldest, at the tail) is
silently elided from watchdog dumps -- exactly the thread that's
usually wanted.

The hardcoded value is moved to a new internal macro
`_Py_TRACEBACK_MAX_NTHREADS` in `pycore_traceback.h` so the in-tree
fatal-signal callers all reference one source of truth.
2026-04-30 09:27:57 -04:00
Pieter Eendebak
7fe51ceae8
gh-149049: Fix jit binary op stack underflow (GH-149076) 2026-04-30 10:36:04 +01:00
Tian Gao
234c12c0fc
GH-145378: Use PyREPL as the default input console for pdb (#145379) 2026-04-29 22:55:09 -07:00
Jelle Zijlstra
16952218d0
gh-149083: Convert dataclasses.MISSING and dataclasses.KW_ONLY to sentinels (#149086)
There were comments claiming these were implemented as custom classes to give a nicer
repr(), but the repr() wasn't all that nice:

>>> repr(dataclasses.MISSING)
'<dataclasses._MISSING_TYPE object at 0x1005e7e00>'
>>> repr(dataclasses.KW_ONLY)
'<dataclasses._KW_ONLY_TYPE object at 0x100884050>'

Sentinels are conceptually the right tool for these, so let's use them.

This does change the repr() of these two objects.
2026-04-29 19:39:29 -07:00
Hugo van Kemenade
8851a06e6e
gh-149026: Add colour to pickletools CLI output (#149027)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-04-29 18:33:05 +03:00
Victor Stinner
025a82f138
gh-149148: Upgrade bundled pip to 26.1 (#149150)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-29 17:36:01 +03:00
Jansen Price
f1588d460d
gh-148740: Fix uuid CLI with custom UUIDs for UUIDv3/v5 namespaces (#148741)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-04-29 15:44:22 +02:00
Irit Katriel
16f292ef4e
gh-149122: Fix segfault in compiler when certain builtin functions are passed a coroutine as arg (#149138) 2026-04-29 13:35:51 +00:00
Weilin Du
4a5d25c26c
gh-135528: Support more second-level domain names in http.cookiejar (#135820)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-04-29 11:33:51 +00:00
John Belmonte
8a8d737be2
gh-108951: document addition of TaskGroup.cancel() (#149031)
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-04-28 09:45:55 -07:00
Hai Zhu
be968c7210
gh-148571: [JIT] Preserve family-head recorder layouts for specialized opcode families (GH-148730)
* Records the same objects for each member of family before execution
* Records derived values when recording the trace
* This makes sure that specialization, or deoptimization, does not cause invalid values to be recorded
2026-04-28 13:41:16 +01:00
Gregory P. Smith
9a57179d74
GH-83065: Fix import deadlock by implementing hierarchical module locking (GH-137196)
Make _find_and_load() acquire the module locks for the full
dotted-name chain (parent before child) when loading a nested module, so
both threads contend on the same first lock and serialise instead of
deadlocking.

When acquiring a parent's lock would itself deadlock with another thread
that is loading that parent (cross-package circular imports), the parent's
lock is skipped and the partially-initialised parent is accepted -- the
same policy _lock_unlock_module() already applies on the existing code
path -- so concurrent circular imports that worked before continue to work.
2026-04-28 01:06:23 -07:00
Alex Grönholm
29251396a9
gh-125862: Keep ContextDecorator open across generator/coroutine execution (GH-136212)
ContextDecorator and AsyncContextDecorator (and therefore @contextmanager
and @asynccontextmanager used as decorators) now detect generator,
coroutine, and asynchronous generator functions and emit a wrapper of the
matching kind, so the context manager spans iteration or await rather than
just the call that constructs the lazy object.  Wrapped generators are
explicitly closed when iteration ends.

For asynchronous generator wrappers, values passed via asend() and
exceptions via athrow() are not forwarded to the wrapped generator.

AsyncContextDecorator now also accepts synchronous functions and
generators, returning an asynchronous wrapper; ContextDecorator remains
the recommended choice for those.

inspect.isgeneratorfunction(), iscoroutinefunction(), and
isasyncgenfunction() now return True for the decorated result when the
input is of that kind.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-04-28 05:26:38 +00:00
Brian Schubert
d2f506ae07
gh-137600: Promote ast node constructor deprecation warnings to errors (#137601)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-04-28 02:51:06 +00:00
Jelle Zijlstra
29a92abb60
gh-148829: Implement PEP 661 (#148831)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-27 19:28:30 -07:00
Maurycy Pawłowski-Wieroński
0efd679a6c
gh-148252: Avoid overflow in _remote_debugging binary reader bounds checks (#148972) 2026-04-28 00:06:23 +01:00
Stan Ulbrych
005555a3f0
gh-149017: Upgrade bundled Expat to 2.8.0 (#149020) 2026-04-27 21:22:35 +01:00
Serhiy Storchaka
fc829e8875
gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591)
Use ZipFile.extractall() to sanitize file names and extract files.

Files with invalid names (e.g. absolute paths) are now skipped.

Files containing ".." in the name are no longer skipped.
2026-04-27 21:43:15 +03:00
Salvo 'LtWorf' Tomaselli
f4a726da40
GH-135357: Add socket.SO_PASSRIGHTS constant (#135355)
Constant added to Linux 6.16. See the LWN article:
https://lwn.net/Articles/1023085/

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-04-27 13:12:34 +00:00
Hugo van Kemenade
1e7dfbce93
gh-148991: Add colour to tokenize CLI output (#148992)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-26 22:14:33 +03:00
zSirius
5d416324c5
gh-146455: Fix O(N²) in add_const() after constant folding moved to CFG (#146456)
The add_const() function in flowgraph.c uses a linear search over the
consts list to find the index of a constant. After gh-126835 moved
constant folding from the AST optimizer to the CFG optimizer, this
function is now called N times for N inner tuple elements during
fold_tuple_of_constants(), resulting in O(N²) total time.

Fix by maintaining an auxiliary _Py_hashtable_t that maps object
pointers to their indices in the consts list, providing O(1) lookup.

For a file with 100,000 constant 2-tuples:
- Before: 10.38s (add_const occupies 83.76% of CPU time)
- After:  1.48s
2026-04-26 15:15:24 +03:00
Stan Ulbrych
6d4ca16f47
gh-148981: Add color parameter to ast.dump (#148982)
And turn on color for the `ast` module CLI.
2026-04-26 10:15:54 +01:00
Daniel Hollas
0a39730ecd
gh-137855: Lazy import inspect module in dataclasses (#144387)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-25 22:57:38 -07:00
Gregory P. Smith
c5fcdb4a9b
gh-146311: Reject non-canonical padding bits in base32, 64, & 85 decoding (GH-146312)
Add `canonical=False` keyword argument to `a2b_base64`, `a2b_base32`, `a2b_base85`, and `a2b_ascii85` (and their `base64` module wrappers). When `canonical=True`, non-canonical encodings are rejected per [RFC 4648 section 3.5](https://datatracker.ietf.org/doc/html/rfc4648.html#section-3.5).

This is independent of `strict_mode`.

For base85/ascii85, the check also rejects single-character final groups (never produced by a conforming encoder) and verifies partial group padding matches what the encoder would produce.

Co-authored-by: Serhiy Storchaka via lots of great code review!
2026-04-25 16:02:51 -07:00
sobolevn
85d3bcd4f3
gh-134690: Removed deprecated codetype.co_lnotab (#134691) 2026-04-25 19:13:48 +03:00