Serhiy Storchaka [Thu, 30 Oct 2025 13:55:39 +0000 (15:55 +0200)]
gh-135801: Improve filtering by module in warn_explicit() without module argument (GH-140151)
* Try to match the module name pattern with module names constructed
starting from different parent directories of the filename.
E.g., for "/path/to/package/module" try to match with
"path.to.package.module", "to.package.module", "package.module" and
"module".
* Ignore trailing "/__init__.py".
* Ignore trailing ".pyw" on Windows.
* Keep matching with the full filename (without optional ".py" extension)
for compatibility.
* Only ignore the case of the ".py" extension on Windows.
Cody Maloney [Wed, 29 Oct 2025 12:33:44 +0000 (05:33 -0700)]
gh-140082: Forward colorizing from libregrtest to unittest (#140083)
libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.
Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-140702: Add test skip for Unix Datagram tests on iOS when on Github Actions (#140740)
Exposes the GITHUB_ACTIONS environment variable to iOS simulator test runs, and
uses this variable to skip a Unix Datagram socketserver test that is unreliable
in the iOS GitHub Actions environment.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Peter Bierma [Tue, 28 Oct 2025 13:07:19 +0000 (09:07 -0400)]
gh-140544: Always assume that thread locals are available (GH-140690)
Python has required thread local support since 3.12 (see GH-103324). By assuming that thread locals are always supported, we can improve the performance of third-party extensions by allowing them to access the attached thread and interpreter states directly.
Cody Maloney [Mon, 27 Oct 2025 18:06:46 +0000 (11:06 -0700)]
gh-140607: Validate returned byte count in RawIOBase.read (#140611)
While `RawIOBase.readinto` should return a count of bytes between 0 and
the length of the given buffer, it is not required to. Add validation
inside RawIOBase.read() that the returned byte count is valid.
Co-authored-by: Shamil <ashm.tech@proton.me> Co-authored-by: Victor Stinner <vstinner@python.org>
Alper [Mon, 27 Oct 2025 13:52:30 +0000 (06:52 -0700)]
gh-116738: Use PyMutex for bz2 module (gh-140555)
The methods are already wrapped with a lock, which makes them thread-safe in
free-threaded build. This replaces `PyThread_acquire_lock` with `PyMutex` and
removes some macros and allocation handling code.
Also add a test for free-threading to ensure we aren't getting data races and
that the locking is working.
Stan Ulbrych [Sun, 26 Oct 2025 11:01:04 +0000 (11:01 +0000)]
gh-76007: Deprecate `__version__` attribute in `decimal` (#140302)
Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Kumar Aditya [Fri, 24 Oct 2025 14:32:17 +0000 (20:02 +0530)]
gh-140414: add fastpath for current running loop in `asyncio.all_tasks` (#140542)
Optimize `asyncio.all_tasks()` for the common case where the event loop is running in the current thread by avoiding stop-the-world pauses and locking.
This optimization is already present for `asyncio.current_task()` so we do the same for `asyncio.all_tasks()`.
Victor Stinner [Thu, 23 Oct 2025 20:35:17 +0000 (22:35 +0200)]
gh-83714: Set os.statx().stx_mode to None if missing from stx_mask (#140484)
* Set stx_mode to None if STATX_TYPE|STATX_MODE is missing from
stx_mask.
* Enhance os.statx() tests.
* statx_result structure: remove atime_sec, btime_sec, ctime_sec and
mtime_sec members. Compute them on demand when stx_atime,
stx_btime, stx_ctime and stx_mtime are read.
* Doc: fix statx members sorting.
Abhishek Tiwari [Thu, 23 Oct 2025 17:05:12 +0000 (22:35 +0530)]
gh-140443: Use `fma` in `loghelper` to improve accuracy of log for very large integers (#140469)
* gh-140443:use fma in loghelper to improve accuracy of log for very large integers
Use fused multiply-add in log_helper() for huge ints.
Saving a rounding here is remarkably effective. Across some millions
of randomized test cases with ints up to a billion bits, on Windows
and using log10, the ULP error distribution was dramatically
flattened, and its range was nearly cut in half. In fact, the largest
error Tim saw was under 0.6 ULP.
---------
Co-authored-by: abhi210 <27881020+Abhi210@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Sam Gross [Thu, 23 Oct 2025 14:18:13 +0000 (10:18 -0400)]
gh-140431: Fix GC crash due to partially initialized coroutines (gh-140470)
The `make_gen()` function creates and tracks generator/coro objects, but
doesn't fully initialize all the fields. At a minimum, we need to
initialize all the fields that may be accessed by gen_traverse because
the call to `compute_cr_origin()` can trigger a GC.
Stefano Rivera [Wed, 22 Oct 2025 16:36:12 +0000 (09:36 -0700)]
gh-130317: Fix SNaN broken tests on HP PA RISC (#140452)
While looking at #140028, I found some unrelated test regressions in the
3.14 cycle. These seem to all come from #130317. From what I can tell,
that made Python more correct than it was before. According to [0], HP PA
RISC uses 1 for SNaN and thus a 0 for QNaN.
Emma Smith [Tue, 21 Oct 2025 21:48:29 +0000 (14:48 -0700)]
gh-132835: Add defensive NULL checks to MRO resolution (GH-134763)
Currently, there are a few places where tp_mro could theoretically
become NULL, but do not in practice. This commit adds defensive checks for
NULL values to ensure that any changes do not introduce a crash and that
state invariants are upheld.
The assertions added in this commit are all instances where a NULL value would get passed to something not expecting a NULL, so it is better to catch an assertion failure than crash later on.
There are a few cases where it is OK for the return of lookup_tp_mro to be NULL, such as when passed to is_subtype_with_mro, which handles this explicitly.
Jeffrey Bosboom [Tue, 21 Oct 2025 16:13:14 +0000 (09:13 -0700)]
gh-83714: Check for struct statx members in configure (#140402)
Some systems have the definitions of the mask bits without having the
corresponding members in struct statx. Add configure checks for members
added after Linux 4.11 (when statx itself was added).
David Ellis [Tue, 21 Oct 2025 15:57:43 +0000 (16:57 +0100)]
gh-138764: annotationlib: Make `call_annotate_function` fallback to using `VALUE` annotations if both the requested format and `VALUE_WITH_FAKE_GLOBALS` are not implemented (#138803)