gh-135307: Fix email error when policy max_line_length is set to 0 or None (#135367)
RDM: Like the change made in a earlier PR to the folder, we can/must use 'maxlen' as a stand in for 'unlimited' when computing line lengths when max_line_length is 0 or None; otherwise the computation results in a traceback.
R. David Murray [Fri, 31 Oct 2025 13:09:22 +0000 (09:09 -0400)]
gh-57665: Remove 'response_class' from getresponse docstring. (#140707)
Remove 'response_class' from getresponse docstring.
This variable is not documented as part of the API in the standard
library documentation; it should be considered as an implementation
detail and as such should not be included in the doc string.
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.