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)
Jeffrey Bosboom [Tue, 21 Oct 2025 15:54:00 +0000 (08:54 -0700)]
gh-140239: Check for statx on Android (#140395)
Android has Linux's statx, but MACHDEP is "android" on Android, so
configure doesn't check for statx on Android. Base the check for statx
on ac_sys_system instead, which is "Linux-android" on Android, "Linux"
on other Linux distributions, and "AIX" on AIX (which has an
incompatible function named statx).
Mark Shannon [Tue, 21 Oct 2025 14:22:15 +0000 (15:22 +0100)]
GH-139951: Fix major GC performance regression (GH-140262)
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead
* Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
* Support non-UTF-8 shebang and comments if non-UTF-8 encoding is specified.
* Detect decoding error for non-UTF-8 encoding.
* Detect null bytes in source code.
Kumar Aditya [Sat, 18 Oct 2025 11:06:58 +0000 (16:36 +0530)]
gh-140067: Fix memory leak in sub-interpreter creation (#140111) (#140261)
Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally.
Barney Gale [Fri, 17 Oct 2025 21:57:51 +0000 (22:57 +0100)]
GH-133789: Fix unpickling of pathlib objects pickled in Python 3.13 (#133831)
In Python 3.13 (but not 3.12 or 3.14), pathlib classes are defined in
`pathlib._local` rather than `pathlib`. In hindsight this was a mistake,
but it was difficult to predict how the abstract/local split would pan out.
In this patch we re-introduce `pathlib._local` as a stub module that
re-exports the classes from `pathlib`. This allows path objects pickled in
3.13 to be unpicked in 3.14+
Jeffrey Bosboom [Thu, 16 Oct 2025 11:40:47 +0000 (04:40 -0700)]
gh-83714: Check for struct statx.stx_atomic_write_unit_max_opt in configure (#140185)
stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled
by the STATX_WRITE_ATOMIC mask bit added in Linux 6.11. That's safe at
runtime because all kernels clear the reserved space in struct statx and
zero is a valid value for stx_atomic_write_unit_max_opt, and it avoids
allocating another mask bit, which are a limited resource. But it also
means the kernel headers don't provide a way to check whether
stx_atomic_write_unit_max_opt exists, so add a configure check.