gh-154271: Enable socket ancillary data and forkserver on illumos (GH-154273)
illumos declares the socket ancillary-data API (CMSG_*, sendmsg(),
recvmsg()) only under _XOPEN_SOURCE >= 600. __EXTENSIONS__ keeps the
other platform features. This enables the forkserver start method.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-154324: Fix os.sendfile() error reporting on illumos (GH-154327)
illumos sendfile(3EXT) returns the number of transferred bytes by adding
it to the offset without initializing it, so the offset cannot be used to
detect a partial write. Use sendfilev(3EXT), which reports the number of
transferred bytes in an explicit out parameter.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Put common information in an intro section at the beginning, rather
than in a duplicate doc entry for `SequenceMatcher`
- Merge the two doc entries for `Differ`
- Document timing as a CPython implementation detail
- Group examples together
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-154786: Fix crashes on a screen without a terminal (GH-154787)
screen.use() makes its screen current for the callback, so a new_prescr()
screen, which has no terminal, can be current without set_term().
Operations that need a terminal then crashed inside curses.
Raise curses.error instead, checking that stdscr exists.
Dan Shernicoff [Tue, 28 Jul 2026 01:41:17 +0000 (21:41 -0400)]
gh-154746: Update docstring for `collections.Counter` (GH-154792)
Added a note to `collections.Counter`'s docstring that initializing a `Counter` from a `Mapping` or `Counter` will have different behaviour than initializing from other `Iterable`s.
This behaviour was already documented in the canonical docs but is missing from the help() output.
gh-154467: Fix empty (Pdb) prompt when attaching to a process with pdb -p (#154469)
_PdbServer inherits _cmdloop, which wraps cmdloop() in
_maybe_use_pyrepl_as_stdin(). That context manager blanks self.prompt to ''
so that a local pyrepl draws the prompt itself. The remote server, however,
never reads from a local pyrepl -- it transmits self.prompt to the client
over the socket -- so the blanking made it send an empty prompt whenever the
target process had a pyrepl-capable terminal (pyrepl_input is set).
Override _maybe_use_pyrepl_as_stdin() in _PdbServer to a no-op, keeping the
real prompt. Add an integration test that attaches to a target running under
a pty, so PyREPL is genuinely enabled inside it, and asserts the transmitted
prompt is "(Pdb) ".
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-152548: Add a test.support.isolation.runInSubprocess() decorator (GH-152551)
Run a test in a fresh interpreter subprocess, so that it does not share global
or interpreter state with the rest of the test run. It can decorate a test
method (only that method runs in a subprocess) or a TestCase subclass (the
whole class runs in one subprocess, with its setUpClass()/setUp()/tearDown()/
tearDownClass() running there rather than in the parent).
Failures, errors and skips, including those of individual subtests, are
reported for the test; a failure or an error shows the original subprocess
traceback. The subprocess inherits the parent's resource, memory, verbosity
and failfast configuration, so that requires_resource(), bigmemtest() and
similar behave the same in both processes. A decorated test is skipped where
subprocesses are unavailable, since it must spawn one.
The test.support.isolation.runningInSubprocess flag is true in the subprocess,
so that fixtures can choose what to run there.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gh-154751: Fix use-after-free in curses.initscr() after newterm() (GH-154752)
initscr() called while a newterm() screen is current returned a second
window object over that screen's standard window, with no reference to
the screen. Either wrapper could then free the window used by the other.
gh-154744: Improve detection of skipinitialspace in csv.Sniffer (GH-154745)
Detect the padding by parsing the sample both with and without
skipinitialspace and comparing the two readings, instead of testing
whether every field following a delimiter starts with a space.
gh-122931: Allow stable abi3 API extensions to include a multiarch tuple in the filename (GH-152461)
This permits stable ABI extensions for multiple architectures to be
co-installed into the same directory, without clashing with each other,
the same way (non-stable ABI) regular extensions can.
It is listed before the current platform-less suffixes since it's more
specific.
The platform is stored in a new pyconfig.h define & sysconfig
variable, SOABI_PLATFORM.
On some known architectures (FreeBSD, Windows), this
will be undefined/zero; these won't have the new tag (yet).
Add SOABI_PLATFORM & ALT_SOABI the info to
`make pythoninfo` as well.
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
gh-154070: Build the curses module wide by capability, not by name (GH-154071)
configure built the module wide (HAVE_NCURSESW) only for a backend named
ncursesw. Probe for the wide API in the ncurses and auto backends too, so
a widec-built ncurses keeping the plain name (pkgsrc, macOS) is built wide.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gh-93251: Decode localized socket error messages from the locale encoding (GH-154683)
The gai_strerror() and hstrerror() messages were decoded as UTF-8, so
gaierror and herror could be replaced with UnicodeDecodeError if the
message is localized and the locale encoding is not UTF-8.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
gh-153862: Fix spurious color pair in curses window.inch() on a wide build (GH-154703)
winch() returns the whole code point, so inch() replacing only its low
8 bits left the high bits in the color field. Rebuild from
getcchar()'s attributes and color pair.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GH-142035: Fix wrapping of colorized argparse help text (#154634)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-70990: Support bytes addresses of Unix sockets in SysLogHandler (GH-154500)
Only a str address was recognized as a Unix domain socket. A bytes
address, which socket.bind() accepts, fell through to the (host, port)
branch and raised ValueError.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-154580: Fix python-gdb.py pretty-printing non-ASCII strings in non-UTF-8 locales (GH-154581)
The gdb pretty-printer used locale.getpreferredencoding() to decide whether to
escape a character, but gdb writes its output in its host charset. Use
gdb.host_charset() instead. test_strings had the same problem.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Steve Stagg [Fri, 24 Jul 2026 15:25:11 +0000 (16:25 +0100)]
gh-153419: Fix several issues around bytearray __init__ (#153498)
Introduce a bytearray_new() function to ensure that
ob_bytes_object is always set on a bytearray.
Resizing a bytearray to 0 length now explicitly sets
the ob_bytes_object to the empty constant immortal.
Add a check in the 'bytearray init from string'
fast path to ensure there are no active exports.
This fixes asserts/crashes on the following:
- bytearray(1).__init__()
- bytearray().__new__(bytearray).append(1)
- a = bytearray(); b = memoryview(a); a.__init__('x', 'ascii')
gh-76595: Add tests for PyCapsule_Import() (GH-154588)
Add _testcapi helpers to create a capsule with an arbitrary name and to call PyCapsule_Import(), and Python tests covering the current behavior: only the first component of the dotted name is imported, the rest are attribute lookups.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gh-73458: Fix logging.config.listen() on a host without an IPv4 address (GH-154491)
The server is created in a thread which set the "ready" event only after a
successful start, so a failure to start left the caller waiting for that
event forever. Set it also on failure.
The receiver always used AF_INET, which fails if the host has no IPv4
address, for example if "localhost" is only aliased to ::1. Use the family
of the first resolved address in such case.
Also fixes gh-82076.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-153570: Fix use-after-free in bytearray.take_bytes() with a reentrant __index__ (#153572)
bytearray.take_bytes() cached the size before the argument's __index__ call and
used it for the bounds check and the buffer reads, so an __index__ that resizes
the bytearray left it reading freed memory. Re-read the size after __index__,
matching bytearray.__setitem__ (GH-91153).
gh-154525: Skip ncurses find_pair()/alloc_pair() reuse checks before 6.3 (GH-154543)
find_pair() and reuse in alloc_pair() were fixed in ncurses 6.3 (patch 20200411). On earlier versions find_pair() returns -1 and alloc_pair()
allocates a fresh pair instead of reusing an equal one, so
test_dynamic_color_pairs failed on ncurses 6.1 and 6.2.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
John [Wed, 22 Jul 2026 22:43:18 +0000 (23:43 +0100)]
gh-154401: Skip fetching the thread state for non-GC types in `_Py_Dealloc` (GH-154430)
_Py_Dealloc() fetched the current thread state and computed the C
recursion margin on every deallocation, but both are only used by the
trashcan mechanism, which applies only to GC-tracked types. Gate them
behind the Py_TPFLAGS_HAVE_GC check so the common non-GC case (int,
float, str and similar atomic types) skips them.
On platforms where _PyThreadState_GET() reads a _Thread_local via a
function call (e.g. macOS TLV), this removes a call from every non-GC
deallocation.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Create the log file in a fresh directory under a name which has never
been used. On Windows, NTFS file tunneling restored the original
creation time of a file recreated with the same name, which made the
rollover time earlier than the current time and caused an unwanted
rollover.
Also check that the rollover does not happen before the specified time.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-154427: Check the access time in UtimeTests only if it is stored (GH-154428)
HAMMER2 on DragonFly BSD does not store the access time and os.stat()
returns the modification time instead. Probe the file system, like it
is already done for the timestamp resolution.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-154419: Find the fish shell in test_venv (GH-154420)
shutil.which('fish') can find the unrelated "Go Fish" game, which is
shipped on several BSD systems. Search PATH for an executable which
behaves like the fish shell instead.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153291: Fix data race in readline.get_completer() and get_pre_input_hook() (gh-153362)
The setters store these hooks while holding the module critical section
(via set_hook's Py_XSETREF), but the getters read and Py_NewRef the same
fields without it. Annotate both getters with @critical_section, matching
the other readline functions (gh-126895).
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
gh-153741: Harden IDLE GUI tests for newer Tk and display scaling (#153742)
In test_sidebar.test_mousewheel, only use the X11 <Button-4>/<Button-5> events when testing on
x11 Tk before 8.7. Otherwise, use <Mousewheel> as on other systems.
In test_configdialog, assert the 'disabled' state flag alone instead of
the exact ttk state tuple (which transient pointer states break), and
restore the tests' method masks with addCleanup().
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>