Commit graph

131143 commits

Author SHA1 Message Date
Petr Viktorin
9d41e2a534
gh-111264: Add a note about untrusted input to tomllib docs (GH-146209)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-30 16:33:13 +02: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
Petr Viktorin
4599335a83
gh-149122: Fix refleak in codegen (GH-149179) 2026-04-30 10:05:48 +00:00
Pieter Eendebak
7fe51ceae8
gh-149049: Fix jit binary op stack underflow (GH-149076) 2026-04-30 10:36:04 +01:00
Petr Viktorin
a94c7900be
Revert pylock.toml change to make MSI builds pass (#149175)
GH-149058 made MSI installer tests fail. GHA didn't catch this because MSI-related files weren't changed.

This reverts the build.bat change from commit 40dc61a0e0.

Also: a README style nitpick to trigger CI.
2026-04-30 10:30:34 +02: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
ivonastojanovic
d4eee16659
gh-142927: Show module names instead of file paths in flamegraph (#146040) 2026-04-29 10:00:07 +01:00
Jelle Zijlstra
d71e3bc5a0
gh-148829: bump number of static types (#149121) 2026-04-28 18:59:48 -07:00
Stelar
2674c322c6
gh-149119: docs: mention that sentinel does not support subclassing (#149120)
Add note about sentinel objects not supporting subclassing

Clarify that sentinel objects do not support subclassing.
2026-04-28 16:50:53 -07:00
Hugo van Kemenade
40dc61a0e0
Build docs from pylock.toml (#149058) 2026-04-28 21:45:38 +03:00
Hugo van Kemenade
933e2dd6cf
Replace deprecated action with RtD app (#149111) 2026-04-28 17:30:16 +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
ivonastojanovic
993e204ad4
gh-142927: Fix inverted flamegraph width (#148568)
Fix inverted flamegraph width

The inverted view used thread presence as a proxy for self time.
This missed self samples on C-level wrapper frames like _run_code,
where the node's thread always appears in its children too. Those
samples were silently dropped, causing the chart to render narrower
than full width. Now uses the explicit self field on each node
instead of the thread heuristic.
2026-04-28 17:42:21 +01:00
Neko Asakura
2b6a13710f
gh-148211: decompose _SHUFFLE_3_LOAD_CONST_INLINE_BORROW in JIT (GH-148816) 2026-04-28 13:48:23 +01: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
ByteFlow
c8799f137a
gh-149035: Modernize legacy Python patterns in Doc/tutorial/stdlib2.rst (#149036)
Co-authored-by: Copilot <copilot@github.com>
2026-04-28 08:08:23 +03: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
Serhiy Storchaka
3e5a3cb2bd
gh-148529: Minor improvements of the struct module documentation (GH-148565)
* Document that 's' and 'p' accept bytes and bytearray.
* Fix some footnotes.
* Clarify that "string" is a byte string.
* Fix the module docstring.
2026-04-27 21:30:48 +03:00
Mark Shannon
276f474c9a
GH-146073: Add fitness to executor dumps. (GH-148959) 2026-04-27 17:34:09 +01:00
Thomas Kowalski
a386a52d8c
Un-skip previously-broken test_get_type_hints_modules_forwardref (#149048) 2026-04-27 08:30:35 -07: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
Manoj K M
62792c8f77
gh-148868: Increase test coverage for cmath.isinf (#148869) 2026-04-27 09:22:20 +02:00
Anonymous941
54a8921140
Fix typo in ceval.c error message (#148860)
Fix the "multiple values for keyword argument" error message
used when the function's `__qualname__` cannot be retrieved.
2026-04-27 09:21:53 +02:00
Micah Najacht
804c213c89
gh-82665 Mention that HTMLParser.handle_starttag value can be None (#134312)
* Specify boolean attribute behavior in parser

* Tweak wording and example

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>

* Fix backticks

---------

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-04-27 08:27:05 +02:00
Gregory P. Smith
f27e91e372
Document that multiprocessing treats local same-user processes as trusted (GH-149001)
Clarify in the Authentication keys section that the authkey handshake
covers Listener/Client (addressable endpoints) only, not the anonymous
pipes behind Pipe() and Queue, and that isolation between same-user
processes must be arranged at the OS level.
2026-04-26 18:42:13 -07:00
Gregory P. Smith
2754e9a615
gh-47798: Refactor the POSIX subprocess.Popen._communicate selector loop into helpers (GH-149032)
No public API change.  Lift the per-iteration select/read/write loop out of
Popen._communicate (POSIX) into a module-level _communicate_io_posix(), with
small _flush_stdin / _make_input_view / _translate_newlines helpers alongside
it.  Popen._communicate calls the helper and persists the returned input
offset for resume-after-timeout.

Retire the private Popen._remaining_time method in favor of module-level
_deadline_remaining; all call sites (POSIX and Windows) updated.

Defensive behavioural deltas: the stdin and stdout/stderr .close() calls in
the I/O loop now swallow BrokenPipeError / OSError, matching __exit__ and the
no-input path; previously these were bare.

Adds test_communicate_timeout_resume_partial_write to cover _input_offset
bookkeeping across TimeoutExpired/resume.
2026-04-27 00:40:20 +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
e1384cfd25
gh-141473: Speed up subprocess test_communicate_timeout_large_input long tail (#149003)
gh-141473: Speed up test_communicate_timeout_large_input

Replace the slow reader's 30s sleep with a parent-driven wake over a
loopback socket so post-timeout communicate() doesn't block waiting
for the child to wake on its own. Worst-case runtime: ~30s -> <1s.
2026-04-26 04:01:33 +00: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
Maurycy Pawłowski-Wieroński
b2f126c4a0
gh-148989: _remote_debugging: Remove dead code, unnecessary gc state read (#148990)
dead code
2026-04-25 22:28:51 +01:00
Mai Giménez
a2fa63b787
gh-140727: Update tachyon logo (#148965) 2026-04-25 22:27:11 +01:00
sobolevn
85d3bcd4f3
gh-134690: Removed deprecated codetype.co_lnotab (#134691) 2026-04-25 19:13:48 +03:00
Jelle Zijlstra
6d7bbee1d5
gh-148947: dataclasses: fix error on empty __class__ cell (#148948)
Also add a test demonstrating the need for the existing "is oldcls" check.

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-04-25 08:31:22 -07:00
Bartosz Sławecki
5ea3ae7c97
gh-140287: Handle PYTHONSTARTUP script exceptions in the asyncio REPL (#140288) 2026-04-25 15:24:40 +01:00
Bartosz Sławecki
9dab866f9c
gh-148588: Document __lazy_modules__ (#148590) 2026-04-25 15:23:40 +01:00