gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (#149649)
Use exact remote reads for interpreter state, thread state, and
interpreter frame structs instead of pulling full remote pages into the
profiler page cache. This matches the core change from
python/cpython#149585.
The profiler clears the page cache between samples, so live entries are
always packed at the front. Track the live count and only clear/search
that prefix instead of scanning all 1024 slots on the hot path.
Use the frame cache to predict the next thread state and top frame
address, then batch interpreter/thread/frame reads with process_vm_readv
when profiling a Linux target. Reuse prefetched frame buffers in the
frame walker when the prediction is valid.
Cache the last FrameInfo tuple per code object/instruction offset, reuse
cached thread id objects, and append cached parent frames directly on
full frame-cache hits. This cuts Python allocation churn in the
steady-state profiler path.
Caleb [Wed, 20 May 2026 01:36:19 +0000 (21:36 -0400)]
gh-134261: ZipFile - Don't rely on local time for reproducible builds & tests (#134264)
---------
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Emma Smith <emma@emmatyping.dev> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
larryhastings [Tue, 19 May 2026 22:27:04 +0000 (15:27 -0700)]
gh-150042: queue.SimpleQueue.put: fix minor refleak. (GH-150043)
If queue.SimpleQueue.put can't handoff the item to a
waiting thread, and fails to allocate memory when adding
the item to a ringbuf, it would leak a reference. Fixed.
Gregory P. Smith [Tue, 19 May 2026 01:19:06 +0000 (18:19 -0700)]
gh-86533: Make Path.mkdir parent_mode tests umask-independent (#150040)
test_mkdir_with_parent_mode, test_mkdir_parent_mode_deep_hierarchy and
test_mkdir_parent_mode_same_as_mode assert exact directory mode bits but
did not pin the process umask. On buildbots running with a restrictive
umask (e.g. 0o077) the 0o755 leaf was masked down to 0o700, failing the
assertions. Wrap them in os_helper.temp_umask(0o022), matching the
other umask-aware mkdir tests in this file.
Saul Cooperman [Mon, 18 May 2026 23:26:08 +0000 (16:26 -0700)]
gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (#150025)
Remove assertion that could fail in rare race condition.
Replace the coarse critical section wrapping the entire function with
fine-grained sections covering only PyDict_Next + Py_INCREF.
Also handle PyDict_Next returning 0 in the single-item fast path.
Armaan Vakharia [Mon, 18 May 2026 23:00:59 +0000 (16:00 -0700)]
gh-149590: Remove faulthandler_traverse (#150023)
`faulthandler_traverse` visits Python objects owned by `_PyRuntime`, not
by the module instance. With multi-phase init allowing multiple module
instances, each instance's GC traversal decrements `gc_refs` on the same
runtime-owned objects, driving it negative when two instances are
collected simultaneously.
Victor Stinner [Mon, 18 May 2026 22:45:35 +0000 (00:45 +0200)]
gh-149879: Fix multiprocessing tests on Cygwin (#150031)
* Disable AF_UNIX connection family on Cygwin.
* forkserver start method is not available on Cygwin: update tests
for that.
* test_logging calls multiprocessing.get_all_start_methods().
These were all deprecated in 3.9 (bace59d8b8) but without
a runtime deprecation warning. Add it now, so that these
items can be removed in 3.21 per PEP 387.
Victor Stinner [Fri, 15 May 2026 19:32:10 +0000 (21:32 +0200)]
gh-149879: Fix test_signal on Cygwin (#149896)
* Check for SIG_BLOCK instead of pthread_sigmask() to decide if
SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK constants should be
converted to enums.
* Skip ITIMER_VIRTUAL and ITIMER_PROF tests on Cygwin: setitimer()
fails with ItimerError(EINVAL).
Petr Viktorin [Thu, 14 May 2026 16:47:52 +0000 (18:47 +0200)]
Link to existing rules in compound_stmts.rst (GH-149811)
In gh-138418, `!` was added to links to rules that don't exist in
the docs, in order to silence broken link warnings.
However, productionlist doesn't parse the `!`, which ends up in
the rendered documentation. (It's possible that gh-127835 broke
the `!` support.)
Replace the names with ones that appear in docs:
- `star_named_expression` in the grammar corresponds to
`flexible_expression` in the docs
- `star_named_expressions` in the grammar corresponds to
`flexible_expression_list` in the docs
- `named_expression` in the grammar corresponds to
`assignment_expression` in the docs
Having two sets of names isn't great of course. Consolidating them
is tracked in (subissues of) gh-127833.
Gregory P. Smith [Wed, 13 May 2026 17:33:43 +0000 (10:33 -0700)]
gh-87451: Apply CVE-2021-4189 PASV fix to ftplib.ftpcp() (GH-149648)
ftpcp() called parse227() directly and passed the source server's
self-reported PASV IPv4 address to the target server's PORT command,
bypassing the CVE-2021-4189 fix that was applied only to FTP.makepasv().
A malicious source FTP server could use this to redirect the target
server's data connection to an arbitrary host:port (SSRF).
ftpcp() now uses the source server's actual peer address, honoring the
existing trust_server_pasv_ipv4_address opt-out, the same as makepasv().
Thanks to Qi Ding at Aurascape AI for the report. (GHSA-w8c5-q2xf-gf7c)
Barry Warsaw [Wed, 13 May 2026 16:45:25 +0000 (09:45 -0700)]
gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() (#149659)
* Add re-entrant tests for gh-149504
* Add end-to-end integration test coverage
This ensures that future whitebox internal test changes do not regress the
public surface semantics.
* Implement a state class to process .pth and .start files
By using this state class and managing implicit and explicit batching, we make it structurally
impossible to get bitten by re-entrant site startup processing.