Victor Stinner [Thu, 5 Jun 2025 12:43:47 +0000 (14:43 +0200)]
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.
Victor Stinner [Thu, 5 Jun 2025 09:17:03 +0000 (11:17 +0200)]
gh-135124: Change stdout errors in regrtest worker process (#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().
Call setup_process() earlier, before displaying regrtest headers.
Malcolm Smith [Thu, 5 Jun 2025 05:46:16 +0000 (06:46 +0100)]
gh-131531: android.py enhancements to support cibuildwheel (#132870)
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.
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
mpage [Wed, 4 Jun 2025 23:07:58 +0000 (16:07 -0700)]
gh-134889: Fix handling of a few opcodes when optimizing `LOAD_FAST` (#134958)
We were incorrectly handling a few opcodes that leave their operands on the stack. Treat all of these conservatively; assume that they always leave operands on the stack.
Thomas Grainger [Wed, 4 Jun 2025 13:00:25 +0000 (14:00 +0100)]
gh-126483: disable warnings filters mutation in concurrent test (GH-132694)
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.
Sam Gross [Wed, 4 Jun 2025 07:35:56 +0000 (03:35 -0400)]
gh-135099: Only wait on `_PyOS_SigintEvent()` in main thread (GH-135100)
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.
Joe Rickerby [Wed, 4 Jun 2025 00:31:43 +0000 (01:31 +0100)]
gh-135101: When choosing the default simulator device, don't use `simctl --set testing` (#135102)
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.
tpburns [Tue, 3 Jun 2025 16:00:25 +0000 (12:00 -0400)]
gh-134248 test_getallocatedblocks pre-check to ignore immortalized strings (#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.
Itamar Oren [Sat, 31 May 2025 14:29:03 +0000 (07:29 -0700)]
gh-134954: Hard-cap max file descriptors in subprocess test fd_status (#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.
Bénédikt Tran [Sat, 31 May 2025 07:37:47 +0000 (09:37 +0200)]
gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (#134713)
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.
gh-91048: Reorder result tuple of parse_code_object (#134898)
Reorder result tuple of parse_code_object
The standard followed by APIs like pstat.Stats is to take a file, line,
function triplet. The parse_code_object function (and callers exposing
this in Python like RemoteUnwinder.get_stack_trace) return function,
file, line triplets which requires the caller to reorder these when
using it in classes like pstat.Stats.
Sam James [Fri, 30 May 2025 04:42:19 +0000 (05:42 +0100)]
gh-134768: Fix definition of `mt_continue_should_break()` (#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.
`Py_DEBUG` implies `NDEBUG` is undefined, so we can check just that.
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.
Petr Viktorin [Wed, 28 May 2025 13:24:40 +0000 (15:24 +0200)]
gh-128629: Add _Py_PACK_VERSION for CPython's own definitions (GH-134247)
Add _Py_PACK_VERSION for CPython's own definitions
Py_PACK_VERSION was added to limited API in 3.14, so if
Py_LIMITED_API is lower, the macro can't be used.
Add a private version that can be used in CPython headers
for checks like `Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14)`.
Neil Schemenauer [Wed, 28 May 2025 01:27:41 +0000 (18:27 -0700)]
gh-127266: avoid data races when updating type slots (gh-133177)
In the free-threaded build, avoid data races caused by updating type
slots or type flags after the type was initially created. For those
(typically rare) cases, use the stop-the-world mechanism. Remove the
use of atomics when reading or writing type flags.