da-woods [Thu, 18 Jun 2026 12:53:09 +0000 (13:53 +0100)]
gh-141510 Document and test frozendict class matching behaviour (#150799)
Frozendict has `_Py_TPFLAGS_MATCH_SELF` set so works correctly
with the single-arg class matching. However it isn't documented
in the list of classes this works with and it isn't tested.
The test is some way below the other similar tests but anything
else would need a large renumbering.
Serhiy Storchaka [Thu, 18 Jun 2026 12:39:06 +0000 (15:39 +0300)]
gh-86726: Document the full public API of tkinter (GH-151579)
Replace the previously sparse reference documentation with full coverage of
the public API of the tkinter package, written from the Tcl/Tk manual pages,
the existing documentation and the module docstrings.
* Doc/library/tkinter.rst gains a "Reference" section documenting every public
class, method, function and constant of the core module -- the widgets, the
Misc, Wm, Pack, Place, Grid, XView and YView mix-ins, the Variable and image
classes, the module-level functions and the symbolic constants.
* Doc/library/tkinter.ttk.rst, dialog.rst, tkinter.font.rst and the other
module pages document their remaining classes, methods and functions.
The descriptions are Python-oriented (correct return types -- tuples rather
than Tcl lists, booleans, integers, None on cancellation, and so on) and were
checked against the Tcl/Tk 9.1 manual pages and the implementation.
versionadded, versionchanged and deprecated directives are added for the
public API, determined from the git history relative to Python 3.0: the
tkinter.ttk module (3.1); the Text, Wm, Menu and Misc methods exposing Tk 8.5
features (3.3); and the many later additions and behavior changes up to 3.15.
The Tk version required by features added after Tk 8.6 is noted as well. The
bundled Tcl/Tk version is updated to 9.0 and the manual-page links point at
the tcl9.0 reference.
--------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
The initial implementation of PEP 820 worsened the error message
when non-types are given as base types in Py_tp_bases & Py_tp_base.
Bring back the 'bases must be types' wording and add a 'got' note for
easier debugging.
Improve slot ID documentation, and soft-deprecate Py_tp_base
(as per the PEP).
Victor Stinner [Wed, 17 Jun 2026 11:02:22 +0000 (13:02 +0200)]
gh-151593: Use timeout on GitHub Action TSan jobs (#151594)
Use a timeout of 15 minutes for --tsan command and a timeout of 10
minutes for --tsan-parallel command. Display also the slowest tests
to help adjusting these timeouts later if needed.
Victor Stinner [Wed, 17 Jun 2026 08:23:57 +0000 (10:23 +0200)]
gh-151546: Fix stack limits on musl (#151548)
If the thread stack size is set by linker flags, pass the stack size
to Python/ceval.c via the new _Py_LINKER_THREAD_STACK_SIZE variable
to set Py_C_STACK_SIZE macro.
Itamar Oren [Tue, 16 Jun 2026 16:05:21 +0000 (09:05 -0700)]
gh-151519: Check effective gid in `_test_all_chown_common` group-0 guard (#151521)
The guard that skips the "chown to gid 0 should fail" assertion used
only `os.getgroups()` (supplementary groups). The kernel also accepts
the effective/filesystem gid for chown, so when a process runs with
egid 0 and a non-zero uid (common in containers and user namespaces),
chown(-1, 0) succeeds and the assertion spuriously fails.
Add an `os.getegid() != 0` check alongside the existing
`0 not in os.getgroups()` guard.
Victor Stinner [Mon, 15 Jun 2026 11:11:26 +0000 (13:11 +0200)]
Fix issues reported by cpython-review-toolkit in faulthandler (#151341)
* snprintf() is not async-signal-safe: replace it with
_Py_DumpDecimal().
* Fix tid type from 'long' to 'unsigned long'.
* Replace PyLong_AsLong() with PyLong_AsInt().
* Avoid unnecessary narrowing cast on _Py_write_noraise() call.
Gregory P. Smith [Sun, 14 Jun 2026 12:29:26 +0000 (05:29 -0700)]
Skip test_highly_nested_objects_decoding during the PGO profile task. (GH-151460)
Since the recursion guard tracks real C-stack bounds (gh-91079), this test
asserts that 500k nesting levels overflow the stack margin. On a 64 MiB stack
(some Nix build envs use one that large), the optimized interpreter uses ~160
bytes/level (raises at ~420k levels) so the assertion holds with only ~16%
margin; the PGO *instrumented* stage inlines less, its per-level scanner frames
are smaller, and the 500k-deep decode completes -- "RecursionError not raised"
fails the profile run and aborts `make profile-opt`. Upstream's
skip_if_unlimited_stack_size (gh-143460) only covers RLIM_INFINITY, not
large-finite stacks like ours.
We could also keep playing whack a mole and raise the 500k to a much larger
number... but there's little value in PGO training on this test anyways.
Matt Wozniski [Fri, 12 Jun 2026 01:21:04 +0000 (21:21 -0400)]
gh-151297: Fix undefined behavior in `_PyObject_MiRealloc` (GH-151358)
The standard says that a call to `memcpy` must pass a valid source and
destination pointer even if the size is 0, so we must avoid calling
`memcpy` when our source pointer is NULL. If we don't, an optimizing
compiler can decide that the pointer must be non-NULL based on the
presence of UB, and optimize out checks for null pointers.
Specifically, note that the standard says:
Where an argument declared as size_t n specifies the length of the
array for a function, n can have the value zero on a call to that
function. Unless explicitly stated otherwise in the description of
a particular function in this subclause, pointer arguments on such
a call shall still have valid values, as described in 7.1.4.
And section 7.1.4 says:
If an argument to a function has an invalid value (such as a value
outside the domain of the function, or a pointer outside the address
space of the program, or a null pointer, or a pointer to
non-modifiable storage when the corresponding parameter is not
const-qualified) or a type (after default argument promotion) not
expected by a function with a variable number of arguments, the
behavior is undefined.
The specification for `memcpy` doesn't state that it's allowed to be
called with null pointers, and Linux's `/usr/include/string.h` declares
`memcpy` as `__nonnull ((1, 2))`.
Pieter Eendebak [Thu, 11 Jun 2026 16:38:49 +0000 (18:38 +0200)]
gh-150942: Speed up json.loads array and object decoding (GH-150945)
Append parsed values to the result list with _PyList_AppendTakeRef and
insert key/value pairs with _PyDict_SetItem_Take2, which take ownership of
the references instead of incref-ing on insert and then decref-ing the
local. This removes a reference-count round-trip per element (and, on the
free-threaded build, a per-append lock).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Victor Stinner [Wed, 10 Jun 2026 19:39:03 +0000 (21:39 +0200)]
gh-151278: Fix test_faulthandler on UBSan (#151279)
* Py_FatalError() no longer calls _PyFaulthandler_Fini() if it
doesn't hold the GIL.
* Skip test_faulthandler tests raising signals if run with UBSan.
* Enable test_faulthandler in GitHub Action "Reusable Sanitizer".
Victor Stinner [Wed, 10 Jun 2026 16:43:38 +0000 (18:43 +0200)]
gh-151253: Dump the Python path configuration on _PyCodec_InitRegistry() failure (#151250)
If "import encodings" fails at Python startup, dump the Python path
configuration to help users debugging their configuration. The
encodings module is the first module imported during Python startup.
tonghuaroot (童话) [Wed, 10 Jun 2026 13:03:49 +0000 (21:03 +0800)]
gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (#143987)
Fix crashes in socket.sendmsg() and socket.recvmsg_into() that could
occur if buffer sequences are mutated re-entrantly during argument
parsing via __buffer__ protocol callbacks.
The bug occurs because:
1. PySequence_Fast() returns the original list object when the input
is already a list (not a copy).
2. During iteration, PyObject_GetBuffer() triggers __buffer__
callbacks which may clear the list.
3. Subsequent iterations access invalid memory (heap OOB read).
The fix replaces PySequence_Fast() with PySequence_Tuple() which
always creates a new tuple, ensuring the sequence cannot be mutated
during iteration.
Bernát Gábor [Wed, 10 Jun 2026 13:01:01 +0000 (06:01 -0700)]
gh-89554: Document socket.SocketType as a class (#150683)
socket.SocketType is a class (re-exported from _socket as an alias of
_socket.socket, the base class of socket.socket), but was documented with
the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.
Switch the entry to ".. class::", correct the misleading description
(SocketType is the base class of the socket type, not "type(socket(...))"
which is socket.socket; addresses gh-88427), move it into the Socket
Objects section, and document the socket object methods and attributes
nested under the socket class, dropping the redundant "socket." prefix.