[3.14] gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165) (#135178)
gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165)
Fix Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE macros in the
limited C API 3.11 and older:
Don't treat Py_None, Py_True and Py_False as immortal.
(cherry picked from commit 9258f3da9175134d03f2c8c7c7eed223802ad945)
Co-authored-by: Victor Stinner <vstinner@python.org>
[3.14] gh-135124: Change stdout errors in regrtest worker process (GH-135138) (#135168)
gh-135124: Change stdout errors in regrtest worker process (GH-135138)
Set sys.stdout encoder error handler to backslashreplace in regrtest
workers to avoid UnicodeEncodeError when printing a traceback
or any other non-encodable character.
Move the code from the Regrtest class to setup_process().
[3.14] gh-131531: android.py enhancements to support cibuildwheel (GH-132870) (#135158)
Modifies the environment handling and execution arguments of the Android management
script to support the compilation of third-party binaries, and the use of the testbed to
invoke third-party test code.
(cherry picked from commit 2e1544fd2b0cd46ba93fc51e3cdd47f4781d7499)
Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
[3.14] gh-126483: disable warnings filters mutation in concurrent test (GH-132694) (GH-135131)
The `test_ssl_in_multiple_threads` test failed because `test_check_hostname_idn()`
modified the global warnings filters via `warnings_helper.check_no_resource_warning()`.
Only check for warnings when the context aware warnings feature is enabled, which makes
the warnings filter context-local and thread-safe.
(cherry picked from commit 40c8be0008ecadb5d0dc9a017434b1133a3a6e06)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
[3.14] gh-135099: Only wait on `_PyOS_SigintEvent()` in main thread (GH-135100) (GH-135116)
On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt
the main thread when Ctrl-C is pressed. Previously, we also waited on
the event from other threads, but ignored the result. However, this can
race with interpreter shutdown because the main thread closes the handle
in `_PySignal_Fini` and threads may still be running and using mutexes
during interpreter shtudown.
Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like
we do in other places in the CPython codebase.
(cherry picked from commit cc581f32bf5f15e9f2f89b830ec64ea25684d0cd)
[3.14] gh-135101: When choosing the default simulator device, don't use `simctl --set testing` (GH-135102) (#135113)
On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de731b231ca0c079205f496d1e3d178b4fd3)
[3.14] gh-134248 test_getallocatedblocks pre-check to ignore immortalized strings (GH-134871) (#135095)
gh-134248 test_getallocatedblocks pre-check to ignore immortalized strings (GH-134871)
When sanity checking against gettotalrefcount(), we exclude the blocks for
immortalized strings since their references are not tracked/reported. This
now matches refleak.py's book-keeping using the same functions.
(cherry picked from commit 54ca55978e305ebb099d1b49633211597625bd52)
[3.14] gh-132813: Improve error messages for incorrect types and values of csv.Dialog attributes (GH-133241) (GH-135050)
Make them similar to PyArg_Parse error messages, mention None as
a possible value, show a wrong type and the string length.
(cherry picked from commit df98a47a61a274eb7427c6201ddabec9ffd30b0a)
[3.14] gh-134908: Protect `textiowrapper_iternext` with critical section (gh-134910) (gh-135039)
The `textiowrapper_iternext` function called `_textiowrapper_writeflush`, but did not
use a critical section, making it racy in free-threaded builds.
(cherry picked from commit 44fb7c361cb24dcf9989a7a1cfee4f6aad5c81aa)
Bénédikt Tran [Sun, 1 Jun 2025 08:26:56 +0000 (10:26 +0200)]
[3.14] gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (GH-134713) (#134961)
OpenSSL and HACL*-based hash functions constructors now support both `data` and `string` parameters.
Previously these constructor functions inconsistently supported sometimes `data` and sometimes `string`,
while the documentation expected `data` to be given in all cases.
[3.14] gh-134970: Fix exception message in argparse module (GH-134971) (GH-134991)
Fix the "unknown action" exception in argparse.ArgumentParser.add_argument_group()
to correctly replace the action class.
(cherry picked from commit 965c48056633d3f4b41520c8cd07f0275f00fb4c)
[3.14] gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658) (#134964)
gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658)
random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78aa297f0de0d038742495709185bef5)
[3.14] gh-134954: Hard-cap max file descriptors in subprocess test fd_status (GH-134955) (#134980)
gh-134954: Hard-cap max file descriptors in subprocess test fd_status (GH-134955)
* Hard-cap max file descriptors in subprocess test fd_status
On some systems, `SC_OPEN_MAX` may return a very large value (i.e. 10**30), leading to the subprocess test timing out (or run forever).
Prevent this situation by applying a hard cap on how many file descriptors are checked.
[3.14] gh-134857: Improve error report for doctests run with unittest (GH-134858) (GH-134903)
Remove doctest module frames from tracebacks and redundant newline
character from a failure message.
(cherry picked from commit cb8a72b301f47e76d93a7fe5b259e9a5758792e1)
[3.14] gh-134768: Fix definition of `mt_continue_should_break()` (GH-134769) (#134916)
gh-134768: Fix definition of `mt_continue_should_break()` (GH-134769)
In 121ed71f4e395948d313249b2ad33e1e21581f8a, mt_continue_should_break
was changed to be guarded by `Py_DEBUG`, but it's used in `compress_mt_continue_lock_held`
with just `assert`, so it needs to be available when `NDEBUG` is undefined
too.
The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple. We're also adding some explicit type checks.
This is a follow-up to gh-133221/gh-133528.
(cherry picked from commit dafd14146f7, AKA gh-134900)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This adds a warning about the possibly-missing NUL terminator, but in a way
that doesn't make it sound like a bug/wart.
(cherry picked from commit b783e1791b2076ef560104f8207156d75859c0a6)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Notice the "\x91" byte at the end of the first line: it's the
non-ASCII U+00E6 character encoded to the OEM cp437 code page.
(cherry picked from commit 91618278e7cd1ffc222efa03bb5334bd5a13dc5b)
Co-authored-by: Victor Stinner <vstinner@python.org>
[3.14] Fix typing.TYPE_CHECKING docs to reflect PEP 649. (GH-134813) (#134822)
Fix typing.TYPE_CHECKING docs to reflect PEP 649. (GH-134813)
typing.TYPE_CHECKING should no longer steer users towards
manual or automatic stringization (and PEP 563); PEP 649
makes all that unnecessary.
(cherry picked from commit d7256ae4d781932b3b43b162e8425abdb134afa6)
[3.14] gh-134679: Fix assertion failure in QSBR (gh-134811) (gh-134814)
This is the same underlying bug as gh-130519. The destructor may call
arbitrary code, changing the `tstate->qsbr pointer` and invalidating the
old `struct _qsbr_thread_state`.
(cherry picked from commit a4d37f88b66bc9a66b2ab277aa66a2a6b20821fa)
[3.14] gh-134789: Document del s[i] operation for mutable sequences (GH-134804) (#134808)
gh-134789: Document del s[i] operation for mutable sequences (GH-134804)
[main] Update stdtypes.rst
- Added explicit mention of `del s[i]` (item deletion by index) to the Mutable Sequence Types section.
- Clarified that this operation removes the item at the specified index from the sequence.
- Addresses issue GH-134789.
(cherry picked from commit 967f361993c9c97eb3ff3076a409b78ea32938df)
[3.14] gh-132775: Always Set __builtins__ In _PyFunction_FromXIData() (gh-134794)
This is a small follow-up to gh-133481. There's a corner case
in the behavior of PyImport_ImportModuleAttrString(), where
it expects __builtins__ to be set if __globals__ is set.
(cherry picked from commit 9b5e80000, AKA gh-134758)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Steve Dower <steve.dower@python.org>
[3.14] gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (GH-134777) (GH-134781)
gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (GH-134777)
(cherry picked from commit 8704d6b39139d2b1c3dd871590188fb7deb8aaad)
[3.14] gh-134675: Add t-string prefixes to tokenizer module, lexical analysis doc, and add a test to make sure we catch this error in the future. (GH-134734) (#134739)
gh-134675: Add t-string prefixes to tokenizer module, lexical analysis doc, and add a test to make sure we catch this error in the future. (GH-134734)
* Add t-string prefixes to _all_string_prefixes, and add a test to make sure we catch this error in the future.
[3.14] gh-119180: Updates to PEP 649/749 docs (GH-134640) (#134731)
gh-119180: Updates to PEP 649/749 docs (GH-134640)
- Mention (again) that `type.__annotations__` is unsafe. It is now safe
when using only classes defined under PEP 649 semantics, but not with
classes defined using `from __future__ import annotations`.
- Mention that annotations on instances no longer work. There was already
an issue about this.
- Mention the general changes in the "Porting to Python 3.14" section.
- `annotationlib` was proposed by PEP-749, not PEP-649.
(cherry picked from commit 7291eaba8b20b19e7971d43d88286d5820e5eb56)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Emma Smith <emma@emmatyping.dev> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
[3.14] gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (GH-133415) (#133796)
gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (GH-133415)
This check is potentially problematic because it could force evaluation of
annotations unnecessarily. This doesn't trigger for builtin objects (functions,
classes, or modules) with annotations, but it could trigger for third-party objects.
The check was not particularly useful anyway, because it succeeds if ``__annotations__``
is a dict or None, so the only thing this did was guard against objects that have an
``__annotations__`` attribute that is of some other type. That doesn't seem particularly
useful, so I just removed the check.
(cherry picked from commit cb6596c6aa30c8c3213c8746d5590e6e2757a6c1)