Emma Smith [Mon, 23 Jun 2025 10:28:05 +0000 (06:28 -0400)]
gh-134986: Catch PermissionError when trying to call perf in tests (#134987)
Using Ubuntu 24.04 on the Windows Subsystem for Linux, perf will raise a
`PermissionError` instead of `FileNotFoundError`. This commit modifies
the tests to catch that.
Kattni [Sun, 22 Jun 2025 04:51:23 +0000 (00:51 -0400)]
patchcheck: use URL paths to identify upstream remote (GH-135806)
* find defined "(fetch)" remotes with "python/cpython" in their URL
* if there is exactly one, use that remote name
* if there is one named "upstream", "origin", or "python",
use that remote (in that precedence order)
* otherwise report an error listing the defined remotes
Bénédikt Tran [Sat, 21 Jun 2025 12:32:00 +0000 (14:32 +0200)]
gh-135532: optimize calls to `PyMem_Malloc` in SHAKE digest computation (#135744)
- Add a fast path when the digest length is 0 to avoid calling useless functions.
- Directly allocate via `PyBytes_FromStringAndSize(NULL, length)` when possible.
Bénédikt Tran [Sat, 21 Jun 2025 09:43:30 +0000 (11:43 +0200)]
gh-135759: consistently reject negative sizes in SHAKE digests (#135767)
Passing a negative digest length to `_hashilb.HASHXOF.[hex]digest()` now
raises a ValueError instead of a MemoryError or a SystemError. This makes
the behavior consistent with that of `_sha3.shake_{128,256}.[hex]digest`.
Hood Chatham [Sat, 21 Jun 2025 06:06:59 +0000 (23:06 -0700)]
gh-127146: Skip test_os.test_mode for Emscripten (#135764)
Temporarily skip test_os.test_mode on Emscripten; this fails consistently
on the buildbot, but not on other test configurations. Reported as #135783
for follow up.
Eric Snow [Fri, 20 Jun 2025 20:26:32 +0000 (14:26 -0600)]
gh-135698: Fix Cross-interpreter Queue.full() With Negative/Default max_size (gh-135724)
We weren't handling non-positive maxsize values (including the default) properly
in Queue.full(). This change fixes that and adjusts an associated assert.
Eric Snow [Wed, 18 Jun 2025 23:57:14 +0000 (17:57 -0600)]
gh-133485: Use interpreters.Interpreter in InterpreterPoolExecutor (gh-133957)
Most importantly, this resolves the issues with functions and types defined in __main__.
It also expands the number of supported objects and simplifies the implementation.
Serhiy Storchaka [Wed, 18 Jun 2025 15:26:01 +0000 (18:26 +0300)]
gh-135376: Fix and improve test_random (GH-135377)
* Remove duplicated code. Tests for Random and SystemRandom now share
the code.
* Move implementation agnostic tests that was only run for SystemRandom,
so they are now run for Random too.
* Add tests for __index__() support.
* Add tests for randint().
Duane Griffin [Wed, 18 Jun 2025 12:17:02 +0000 (00:17 +1200)]
gh-135335: flush stdout/stderr in forkserver after preloading modules (#135338)
If a preloaded module writes to stdout or stderr, and the stream is buffered,
child processes will inherit the buffered data after forking. Attempt to
prevent this by flushing the streams after preload.
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
Hood Chatham [Wed, 18 Jun 2025 03:20:43 +0000 (20:20 -0700)]
gh-127146: Emscripten: Fix pathlib glob_dotdot test (#135624)
The Emscripten path resolver uses the same mechanism for resolving `..`
at a file system root as for resolving symlinks. This is because
roots don't store their mountpoints. If the parent of a node is itself,
it is a root but it might be a mountpoint in some other file system.
If a path has enough `..`'s at the root, it will return ELOOP.
Enough turns out to be 49.
Emscripten currently `gethostbyname_r()` returns an incorrect
IP address for `localhost`. Will be resolved by upstream PR:
https://github.com/emscripten-core/emscripten/pull/24593
As noted in the new tests, there are a few situations we must carefully accommodate
for functions that get pickled during interp.call(). We do so by running the script
from the main interpreter's __main__ module in a hidden module in the other
interpreter. That hidden module is used as the function __globals__.
Ken Jin [Tue, 17 Jun 2025 15:25:53 +0000 (23:25 +0800)]
gh-134584: Decref elimination for float ops in the JIT (GH-134588)
This PR adds a PyJitRef API to the JIT's optimizer that mimics the _PyStackRef API. This allows it to track references and their stack lifetimes properly. Thus opening up the doorway to refcount elimination in the JIT.
Michał Górny [Tue, 17 Jun 2025 08:05:04 +0000 (10:05 +0200)]
gh-134632: Fix `build-details.json` to use `INCLUDEPY` path (#134633)
* gh-134632: Fix `build-details.json` to use `INCLUDEPY` path
Fix ``build-details.json`` generation to use ``INCLUDEPY``, in order to
reference the ``pythonX.Y`` subdirectory of the include directory, as
required in :pep:`739`, instead of the top-level include directory.
* test_build_details: Add tests for the c_api section
* test_build_details: Expect pkgconfig for CPython unconditionally
Ned Deily [Mon, 16 Jun 2025 23:35:59 +0000 (01:35 +0200)]
gh-119132: Update 'Using Python on macOS' documentation. (#135591)
Remove `experimental` qualification for free-threading in the document text. Note that images included in the document will be updated later in the release cycle.
Eric Snow [Mon, 16 Jun 2025 23:34:19 +0000 (17:34 -0600)]
gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135491)
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true. This allows those functions to be run with Interpreter.call().
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check
so that we only check if the dictionary is modified, not if new keys are
added to a different dictionary that shared the same keys object.
Donghee Na [Mon, 16 Jun 2025 14:32:52 +0000 (23:32 +0900)]
gh-119132: Remove "experimental" tag from the CPython free-threading. (gh-135550)
* gh-119132: Remove "experimental" tag from the CPython free-threading build
* Address code review
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* Add NEWS.d
* Regen configure.ac
* Update doc
* Update
* Update
* Update
* Update Doc/howto/free-threading-python.rst
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* Update ctypes.rst
* Update
* Update Doc/howto/free-threading-python.rst
Co-authored-by: T. Wouters <thomas@python.org>
* Apply suggestions from code review
Co-authored-by: T. Wouters <thomas@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: T. Wouters <thomas@python.org>
Dan Lenski [Sun, 15 Jun 2025 19:29:38 +0000 (12:29 -0700)]
gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (#92900)
* gh-67022: Document bytes/str inconsistency in email.header.decode_header()
This function's possible return types have been surprising and error-prone
for the entirety of its Python 3.x history. It can return either:
1. `typing.List[typing.Tuple[bytes, typing.Optional[str]]]` of length >1
2. or `typing.List[typing.Tuple[str, None]]`, of length exactly 1
This means that any user of this function must be prepared to accept either
`bytes` or `str` for the first member of the 2-tuples it returns, which is a
very surprising behavior in Python 3.x, particularly given that the second
member of the tuple is supposed to represent the charset/encoding of the
first member.
This patch documents the behavior of this function, and adds test cases
to demonstrate it.
As discussed in bpo-22833, this cannot be changed in a backwards-compatible
way, and some users of this function depend precisely on the existing
behavior.
Add warnings about obsolescence of 'email.header.decode_header' and 'email.header.make_header' functions.
Recommend use of `email.headerregistry.HeaderRegistry` instead, as suggested
in https://github.com/python/cpython/pull/92900#discussion_r1112472177