[3.14] gh-140041: Fix import of `ctypes` on Android and Cygwin when ABI flags are present (GH-140178) (#140180)
Use sysconfig to determine the full name of libpython, rather than hardcoding
a library name that doesn't have ABI flags.
(cherry picked from commit 7f371ed84ba471bb1b11e79b502f244a9c17ac84)
[3.14] gh-140061: Use `_PyObject_IsUniquelyReferenced()` to check if objects are uniquely referenced (gh-140062) (gh-140157)
The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
(cherry picked from commit 32c264982ec67460642b907dabc3304019318291)
[3.14] GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (GH-140059) (#140107)
GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (GH-140059)
(cherry picked from commit ded59f7e8e93274488584574ff2336a98bc4eff6)
[3.14] gh-138772: Fix and improve documentation for turtle color functions (GH-139325) (GH-140047)
Use multiple signatures for clarity.
Explain different forms of bgcolor() in details.
Fix outdated docstrings.
(cherry picked from commit 525dcfe5236ee21b234cad16d2a3d5769e77e0ec)
[3.14] gh-139905: Provide suggestion in error message if `Generic.__init_subclass__` was not called (GH-139943) (#139955)
gh-139905: Provide suggestion in error message if `Generic.__init_subclass__` was not called (GH-139943)
(cherry picked from commit 5776d0d2e08f4d93dcd62d875bae8c1396a04ba4)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Kumar Aditya [Fri, 10 Oct 2025 17:06:02 +0000 (22:36 +0530)]
[3.14] gh-139894: fix incorrect sharing of current task while forking in `asyncio` (GH-139897) (#139913)
* [3.14] gh-139894: fix incorrect sharing of current task while forking in `asyncio` (GH-139897)
Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
(cherry picked from commit b881df47ff1adca515d1de04f689160ddae72142)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
[3.14] gh-139065: Fix trailing space before long word in textwrap (GH-139070) (GH-139902)
Fix trailing space before a wrapped long word if the line length with
a space is exactly "width".
(cherry picked from commit 1c598e04361dbfc9cf465f3a02f83715c11b028c)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Emma Smith <emma@emmatyping.dev> Co-authored-by: Victor Stinner <vstinner@python.org>
[3.14] gh-139391: properly handle `signal.signal()` in `UnixConsole` when called from a non-main thread (GH-139392) (#139858)
gh-139391: properly handle `signal.signal()` in `UnixConsole` when called from a non-main thread (GH-139392)
(cherry picked from commit b8c8b8f1d30767e5358ffa93d41e6e27ca60570d)
[3.14] gh-139742: Add support for Python 3.14 t-string prefixes in IDLE colorizer and tests (GH-139756) (#139831)
gh-139742: Add support for Python 3.14 t-string prefixes in IDLE colorizer and tests (GH-139756)
Add 't' prefix to colorizer.py stringprefix regex to support Python 3.14 template strings.
Add t prefixes to test_colorizer.py source test text and adjust line numbers on test methods.
---------
(cherry picked from commit 6fd141834193e3dc2423e785d97eb127c972a70e)
Kumar Aditya [Wed, 8 Oct 2025 16:46:21 +0000 (22:16 +0530)]
[3.14] gh-139748: fix leaks in AC error paths when using unicode FS-b… (#139789)
* [3.14] gh-139748: fix leaks in AC error paths when using unicode FS-based converters (GH-139765)
(cherry picked from commit b04a57deef66ce08233be57d1ab5873388df2cea)
[3.14] gh-138843: Clean up downloads page (GH-138844) (#139796)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
[3.14] gh-83424: Allow empty name if handle is non-null when create ctypes.CDLL on Windows (GH-136878) (#138546)
gh-83424: Allow empty name if handle is non-null when create ctypes.CDLL on Windows (GH-136878)
(cherry picked from commit ed522ed211b7b9ea9d85a93b5d6ca79b2df3ef58)
Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
[3.14] gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862) (#138224)
gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862)
Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptor
that returns a wrapped function.
(cherry picked from commit 025a2135eff848abf24f9dc52c81386eea9da397)
[3.14] GH-137573: Add test to check that the margin used for overflow protection is larger than the stack space used by the interpreter (GH-137724) (GH-139295)
[3.14] gh-60462: Fix locale.strxfrm() on Solaris (GH-138242) (GH-138448)
It should interpret the result of wcsxfrm() as a sequence of abstract
integers, not a sequence of Unicode code points or using other encoding
scheme that does not preserve ordering.
(cherry picked from commit 482fd0c811a366f25bd076fc73bf37ffb6b3081e)
[3.14] gh-137490: Fix signal.sigwaitinfo() on NetBSD (GH-137523) (GH-138935)
Handle ECANCELED in the same way as EINTR to work around the Posix
violation in the NetBSD's implementation.
(cherry picked from commit 07d0b95b05dfaf5832f44c2fbc956761f9e29571)
[3.14] gh-137463: Update `validate_abstract_methods` in `test_collections.py` (GH-137464) (GH-137503)
Update `validate_abstract_methods` in `test_collections.py`
The test for missing abstract methods in `validate_abstract_methods` incorrectly attempted to instantiate the generated class `C` with an argument (`C(name)`), which always raises a `TypeError: C() takes no arguments`. Although the test originally passes, it passes for the wrong reason.
[3.14] gh-137986: Fix and improve the csv functions docstrings (GH-137987) (GH-138107)
The csv.register_dialect() docstring no longer imply that it returns a dialect.
All functions have now signatures.
(cherry picked from commit aa1dbd4dde32951de2e7438b56d6761001604ee2)
[3.14] gh-71679: Improve tests for repr() of bytes and bytearray (GH-138180) (GH-138182)
* Merge existing tests test_repr_str and test_to_str.
* Add more tests for non-printable and non-ASCII bytes.
* Add tests for special escape sequences ('\t\n\r').
* Add tests for slashes.
* Add more tests for quotes.
* Add tests for subclasses.
* Add test for non-ASCII class name.
* Only apply @check_bytes_warnings for str() tests.
(cherry picked from commit 0dbbf61cc2550428ff99daee367364c688031e1a)
[3.14] gh-138204: Forbid expansion of a shared anonymous mmap on Linux (GH-138220) (GH-138386)
This is a Linux kernel bug which caused a bus error.
https://bugzilla.kernel.org/show_bug.cgi?id=8691
(cherry picked from commit 33fcb0c4a054f646d9d3686c145209a893b09bb0)
[3.14] gh-88375, gh-111788: Fix parsing errors and normalization in robotparser (GH-138502) (GH-138548)
* Don't fail trying to parse weird patterns.
* Don't fail trying to decode non-UTF-8 "robots.txt" files.
* No longer ignore trailing "?" in patterns and URLs.
* Distinguish raw special characters "?", "=" and "&" from the
percent-encoded ones.
* Remove tests that do nothing.
(cherry picked from commit cb7ef18d70a0bc1363799e2dfa475db457155e43)
[3.14] gh-118981: multiprocessing.popen_spawn_posix, fix potential hang (gh-118982) (GH-138605)
fix potential hang.
It can happen that the child crashes right in the beginning for whatever reason. In this case, the parent will hang when writing into the pipe, because the child fd is not closed yet.
The normal pattern is to close the child fds right after the child proc is forked/executed/spawned, so when the child dies, then also the pipes will be closed, and there will be no hang (the parent gets SIGPIPE instead).
(cherry picked from commit 8ed5a2b56cc6a8635e586c641b0b837669f6677b)
Bénédikt Tran [Wed, 8 Oct 2025 10:09:45 +0000 (12:09 +0200)]
[3.14] gh-136912: fix handling of `OverflowError` in `hmac.digest` (GH-136917) (#137116)
The OpenSSL and HACL* implementations of HMAC single-shot
digest computation reject keys whose length exceeds `INT_MAX`
and `UINT32_MAX` respectively. The OpenSSL implementation
also rejects messages whose length exceed `INT_MAX`.
Using such keys in `hmac.digest` previously raised an `OverflowError`
which was propagated to the caller. This commit mitigates this case by
making `hmac.digest` fall back to HMAC's pure Python implementation
which accepts arbitrary large keys or messages.
This change only affects the top-level entrypoint `hmac.digest`, leaving
`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
[3.14] gh-137706: make typing._is_unpacked_typevartuple check for `True` instead of truthy (GH-137712) (#138574)
gh-137706: make typing._is_unpacked_typevartuple check for `True` instead of truthy (GH-137712)
(cherry picked from commit 7e652f402f84b412ec46cec42cb103f489a0087e)
[3.14] GH-137484: Have `Tools/wasm/wasi` use the build triple instead of "build" (GH-137485) (#137487)
GH-137484: Have `Tools/wasm/wasi` use the build triple instead of "build" (GH-37485)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally.
(cherry picked from commit 0953200b136bcb3293cc1bd57a062796ffcd529d)
Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
[3.14] gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None (GH-138814) (#139084)
gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None (GH-138814)
* gh-138813: Default `BaseProcess` `kwargs` to `None` (GH-138814)
Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with
`dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and
matches threading.Thread behavior.
Co-authored-by: Denis Sergeev <newjimbatler00@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>