Commit Graph

131115 Commits

Author SHA1 Message Date
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
Irit Katriel c650b51c32 gh-148973: fix segfault on mismatch between consts size and oparg in compiler (#148974) 2026-04-25 10:47:41 +01:00
scoder db0ee44b93 gh-142186: Revert the unintended value change in the PY_MONITORING_EVENT_* values from gh-146182 (gh-148955)
https://github.com/python/cpython/pull/146182 left an unintended change in the `PY_MONITORING_*` macro values. This change reverts that part to avoid a user visible impact.
2026-04-25 09:05:03 +02:00
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
Gregory P. Smith 665b7dfcfa Improve hash() builtin docstring with caveats. (GH-125229)
Improve  `hash()` builtin docstring with caveats.

Mention its return type and that the value can be expected to change between
processes (hash randomization).

Why? The `hash` builtin gets reached for and used by a lot of people whether it
is the right tool or not. IDEs surface docstrings and people use pydoc and
`help(hash)`.
2026-04-24 16:36:46 +00: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
Diego Russo 9633c5239d GH-126910: Build/link the JIT shim in the Python interpreter (#148872) 2026-04-23 12:23:18 +01:00
Kumar Aditya 29917d51ab gh-148907: fix performance regression in PyType_GetModuleByDef on free-threading (#148908) 2026-04-23 16:42:57 +05:30
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
Nathan Goldbaum 3b9397988d gh-148892: Drop mention of deprecated cibuildwheel option (#148893) 2026-04-23 09:30:35 +05:30
Raymond Hettinger fbc7676df6 Speed up counting in statistics.fmean() (gh-148875) 2026-04-22 22:06:56 -05:00
Victorien 8bf99ae3a9 gh-119180: Document the format parameter in typing.get_type_hints() (#143758)
Do not mention `__annotations__` dictionaries, as this is slightly
outdated since 3.14.

Rewrite the note about possible exceptions for clarity. Also do not
mention imported type aliases, as since 3.12 aliases with the `type`
statement do not suffer from this limitation anymore.
2026-04-23 02:50:15 +00:00
John Seong 75ff1afcb6 gh-142965: Fix Concatenate documentation to reflect valid use cases (#143316)
The documentation previously stated that Concatenate is only valid
when used as the first argument to Callable, but according to PEP 612,
it can also be used when instantiating user-defined generic classes
with ParamSpec parameters.
2026-04-22 19:46:04 -07:00
Vikash Kumar bd7352d807 gh-145194: Fix typing in re tokenizer example (#145198) 2026-04-22 19:40:10 -07: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
Sanjay Janardhan 79321fdce3 gh-148883: Docs: clarify grammar in Counter dictionary methods note (gh-148882) 2026-04-22 17:56:14 -05: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
Isuru Fernando 59b41c8c3b gh-148858: Remove duplicated recipe.yaml files in Tools/pixi-packages (#148859) 2026-04-22 20:50:30 +03:00
Raymond Hettinger b16886528e Additional itertool recipes for running statistics (gh-148879) 2026-04-22 11:52:41 -05:00
KotlinIsland 04fd103713 gh-148207: add additional keywords to typing.TypeVarTuple (#148212) 2026-04-22 06:28:12 -07:00
Mark Shannon f93834ff01 GH-146073: Add example script for dumping JIT traces (GH-148840) 2026-04-22 11:09:05 +01:00