[3.13] gh-154258: Fix mmap.resize() crash on NetBSD growing a shared anonymous mapping (GH-154259) (GH-154264)
NetBSD mremap() returns a mapping whose grown region is not backed when
growing a shared anonymous mapping, so accessing it crashes. Reject it
with ValueError, as is already done on Linux.
(cherry picked from commit 542b98293108a84fa5d904fb6dcf8bfb5080ec93)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
[3.13] gh-154046: docs: fix dead link to codahale timing attacks article in secrets.rst (GH-154047) (#154215)
gh-154046: docs: fix dead link to codahale timing attacks article in secrets.rst (GH-154047)
(cherry picked from commit e8042329b6bb2472b16645c559e4223486b85965)
[3.13] gh-119710: fix asyncio Process.wait() to finish on process exit and not wait for closing of pipes (GH-151983) (#154172)
gh-119710: fix asyncio Process.wait() to finish on process exit and not wait for closing of pipes (GH-151983)
(cherry picked from commit f2521324e6bdf331460abec7c2a88e2d3736b91c)
[3.13] gh-153862: Fix curses window.inch() for non-ASCII characters on a wide build (GH-153863) (GH-154153)
On a wide build, winch() returns the low 8 bits of the character's code
point with no locale conversion, so inch()/mvinch() disagreed with instr()
for a non-ASCII character of an 8-bit locale ('€' under ISO-8859-15 gave
0xAC instead of 0xA4). Re-encode the cell to its locale byte via wctob(),
as ncurses does for getbkgd().
[3.13] gh-153864: Fix curses window.insch() for non-ASCII characters on a wide build (GH-153865) (GH-154154)
On a wide build, winsch() does not locale-decode a byte above 127, unlike
waddch(), so insch()/mvinsch() stored the wrong character for a non-ASCII
byte of an 8-bit locale ('€' 0xA4 under ISO-8859-15 became U+00A4 '¤').
Decode the byte with btowc() and insert it as a wide character, as addch()
effectively does.
[3.13] gh-153926: Fix documented parameter name for `calendar.calendar` and `calendar.prcal` (GH-153927) (#153939)
gh-153926: Fix documented parameter name for `calendar.calendar` and `calendar.prcal` (GH-153927)
gh-153926: Fix documented parameter name for calendar.calendar and calendar.prcal
calendar.calendar() and calendar.prcal() are bound methods of the
module's TextCalendar instance, whose first parameter is named theyear,
but the documentation named it year, so the documented keyword raised
TypeError. Update the documentation to match the real signature, which
also matches the sibling month() and prmonth() functions.
(cherry picked from commit d12434b4661c6be7430002e66a54d920f7d4ca7f)
[3.13] gh-153404: Silently ignore non-decimal digits in robots.txt Crawl-delay and Request-rate (GH-153405) (GH-153832)
str.isdigit() returned True for non-decimal Unicode digits such as
U+00B2 SUPERSCRIPT TWO, which int() then rejected with ValueError.
(cherry picked from commit 597ec2d7e5f8bbd5a1eb9e6780444cae46cec3ea)
[3.13] gh-153550: Modernize the older prose sections of the tkinter documentation (GH-153647) (GH-153775)
Refresh the narrative "Tkinter life preserver" and "Handy reference"
sections to match the overhauled reference (gh-86726 and gh-153549).
* Rework "The packer" into a general "Geometry management" section
covering grid, pack and place, and cross-link it with the Grid, Pack
and Place reference classes.
* Rework "The window manager" and "Coupling widget variables", replacing
the dated App(Frame) examples with direct Tk() and ttk examples.
* Replace page-number citations to Ousterhout's book with links to the
relevant Tk man pages.
* Modernize the tkinter.ttk front matter and its Tcl/Tk links, and add
cross-references between the two documents.
* Reconcile the "Packer options" and "Tk option data types" lists with
the reference, and fill in the empty Entry index list.
* Fix the malformed target-selection list in tkinter.dnd.
* Separate tests for module-level API and for the MimeTypes class.
* Add tests for mimetypes.init() and MimeTypes() with knownfiles and with
explicitly passed files.
Compute probe coordinates from each widget's own realized geometry
instead of hardcoding pixels such as (5, 5) or width - 5, which land on
a different element, or miss it entirely, at a high display scaling.
[3.13] gh-153631: Ensure iOS simulator is running before starting build (GH-153632) (#153675)
Makes a small change to the iOS build script to improve build stability.
xcodebuild doesn't guarantee that the CoreSimulatorService is running before
starting a simulator. If the service isn't running, xcodebuild reports that no
simulators are available, and fails to start the test app. However, simctl
blocks until the simulator is available, and simctl is used to evaluate the
default simulator. So - the iOS build script now unconditionally determines the
default simulator, even if a specific simulator is requested.
(cherry picked from commit 2dc1a91af801ea896e21f6c6e6cc41f57e8268d9)
[3.13] gh-90431: Document cancellation behavior of asyncio.wait() and asyncio.as_completed() (GH-153616) (#153619)
gh-90431: Document cancellation behavior of asyncio.wait() and asyncio.as_completed() (GH-153616)
(cherry picked from commit dd2faeb33d5fa0d2635b91ece6eaebd34c61408c)
[3.13] gh-152614: Add raises to `QueueShutDown` in `asyncio.Queue.put_no_wait` and `asyncio.Queue.get_nowait` documentation methods (GH-152681) (#153567)
gh-152614: Add raises to `QueueShutDown` in `asyncio.Queue.put_no_wait` and `asyncio.Queue.get_nowait` documentation methods (GH-152681)
(cherry picked from commit d1a5b54abaca2b443c7642ef3a7be8e1cd077ae3)
[3.13] gh-86726: Fix and improve tkinter documentation and docstrings (GH-153549) (GH-153557)
Correct inaccurate return-type and option descriptions in the tkinter
reference, and add missing module and class docstrings.
(cherry picked from commit 77cb7560c07feed0d5b144c0c1735e1620c96f51)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-126877: Fix the configure check for Tcl/Tk with optimizing compilers (GH-153543) (GH-153555)
The check assigned the addresses of Tcl_Init() and Tk_Init() to unused
variables, which optimizing compilers can eliminate, so it linked even
when the libraries were missing. Call the functions instead.
(cherry picked from commit ff0a9ae269fa38c21f01bdea1a7ff5d439c4f681)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-128846: Make tkinter tests robust against Tcl/Tk 9.0 (GH-153484)
Backport the test-only parts of the Tcl/Tk 8.7/9.0/9.1 test adaptations so
that test_tkinter and test_ttk pass when Python 3.13 is built against
Tcl/Tk 9.0 (for example the Homebrew build used on macOS), while still
passing against the Tcl/Tk 8.6 that 3.13 ships.
Combines the test changes from:
* gh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 (GH-124156)
* gh-124111: test macOS CI with Tk 9 (GH-137424)
* gh-145736: Fix Tkinter tests for Tk 8.7, 9.0 and 9.1 (GH-145738)
The corresponding non-test changes (Modules/_tkinter.c, Lib/tkinter/ttk.py,
PCbuild and CI configuration) are not backported.
- selectmode: new 'single' and 'multiple' modes
- set(): includes the tree column '#0'
- insert()/selection(): item ids keep the passed value's type
- heading_callback: avoid a double click on the second click
- theme_create_image: don't assert the exact (now scaled) width
(cherry picked from commit d6855c8ad00ffa2bee318b510d0e90573dddbbab)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-88574: Do not swallow the line after a terminating literal in imaplib (GH-153317) (GH-153326)
GH-152751 skipped a spurious blank line after a literal unconditionally,
corrupting a response that ends with a literal (such as a mailbox name
returned by LIST): its empty trailer was mistaken for the blank and the
following line was swallowed.
The blank is now skipped only inside an unclosed parenthesis. After a
literal that ends the response it instead arrives before the next
response and is skipped there.
(cherry picked from commit 6b81784f57c6e7ddef61c8db26bb896b3633dcae)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-153422: Assert bool return type in tkinter tests (GH-153429) (GH-153439) (GH-153443)
The tests for PhotoImage.transparency_get(), Text.debug() and
Treeview.exists() now assert the exact bool type, and the documentation
and docstrings use "true"/"false" instead of "1"/"0".
(cherry picked from commit 1604c80008d72b4c9a5bd789900ecf9aff402c1e)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
identify(5, 5) could run before the notebook reached its requested size,
so the pixel fell outside the first tab and returned ''. Guard it with a
new opt-in wait_until_mapped(full_size=True).
(cherry picked from commit 53b04980284b668c27fc6d5adb0de19d38efe95b)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-152132: Fix bugs in Py_RunMain() (GH-153461) (GH-153466) (#153468)
[3.15] gh-152132: Fix bugs in Py_RunMain() (GH-153461) (GH-153466)
* Check for signals more often. Previously, a pending exception could
be removed by PyErr_Clear().
* Only call _PyInterpreterState_SetNotRunningMain() if
_PyInterpreterState_SetRunningMain() has been called.
* Convert _PyPathConfig_UpdateGlobal() PyStatus error to an
exception.
(cherry picked from commit cecafebc2e30ab2aac5f046ed5c9fbc75d6bfb51)
Co-authored-by: Victor Stinner <vstinner@python.org>
Victor Stinner [Thu, 9 Jul 2026 20:50:58 +0000 (22:50 +0200)]
[3.13] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455) (#153458)
[3.14] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455)
gh-152132: Fix Py_RunMain() to return an exit code (#153446)
* Fix Py_RunMain() to return an exit code, rather than calling
Py_Exit(), when running a script, a command, or the REPL.
* _PyRun_SimpleFile() now logs errors to stderr, for example if setting
__main__.__file__ fails.
* Add tests on Py_RunMain() exitcode.
* Rename functions:
* Change _PyRun_SimpleString(), _PyRun_SimpleFile(), _PyRun_AnyFile() and
_PyRun_InteractiveLoop() return type to PyObject*.
* pymain_repl() now displays the error if PySys_Audit() or
import _pyrepl failed.
* PyRun_SimpleFileExFlags() and PyRun_AnyFileExFlags() now log
PyUnicode_DecodeFSDefault() error. So these functions can no longer
return -1 with an exception set.
[3.13] gh-153406: Raise ValueError, not OverflowError, for out-of-range dates in email.utils.parsedate_to_datetime (GH-153407) (#153433)
email.utils.parsedate_to_datetime documented that it raises ValueError for an invalid date, but it leaked OverflowError when the parsed year or timezone offset was too large for the datetime and timedelta constructors, and that OverflowError also escaped the modern header parsing path since DateHeader.parse only caught ValueError. Wrap the datetime and timezone construction so an OverflowError is re-raised as a ValueError with the original chained as the cause, which restores the documented contract and lets the existing header handler record an InvalidDateDefect instead of raising.
(cherry picked from commit 37a26b9b94b147b5d683bfce0ef5a4c2fbc21085)
Barry Warsaw [Thu, 9 Jul 2026 19:40:59 +0000 (12:40 -0700)]
[3.13] gh-153056: Backport the relevant bits of (#153057) (#153369)
gh-153056: Backport the relevant bits of (#153057)
The data race for compiling the string.Template pattern in free-threading builds is not relevant for
3.13, due to the older string.Template and string.py module implementation. However, the secondary
bug identified by that isue is still relevant here, and fixed in this branch:
As a side effect, a subclass that supplies an already-compiled pattern now works too; previously
it raised the same ValueError at class definition.
* Document that the pattern attribute accepts a string or a compiled regex
* Comment the three states of pattern and note the documented-behavior fix in NEWS
* Update Doc/library/string.rst
[3.13] gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments (GH-153423) (GH-153432)
IMAP4.select() and IMAP4.uid() formatted the mailbox and command argument
with %s in their error messages, which raised BytesWarning under -bb when the
argument was bytes and masked the real error. Use %r instead, which is safe
for bytes and also quotes the value.
(cherry picked from commit 11f1b70f4c981b781aaa94427dc1fceb637b2187)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-47005: fix do_open() to let regular headers override unredirected … (GH-146506) (#153379)
gh-47005: fix do_open() to let regular headers override unredirected … (GH-146506)
AbstractHTTPHandler.do_open() was building the request header dict by
starting with unredirected_hdrs and only inserting regular headers that
were not already present, giving unredirected headers priority. This
contradicts get_header() and header_items(), both of which give regular
headers the higher priority.
Fix by unconditionally updating with req.headers so that a header set
via add_header() always overrides one set via add_unredirected_header().
[3.13] gh-143990: Preserve the size when creating a Font from a named font (GH-153267) (GH-153323) (GH-153342)
tkinter.font.Font now copies the options of a named font (via "font
configure") instead of the options resolved by "font actual", which
would resolve a size specified in pixels (a negative size) to points.
A font description is still resolved, as it cannot be parsed otherwise.
Font.copy(), which has always been equivalent to constructing a Font
from the original font, is updated to match and now preserves the size
too.
[3.13] gh-86017: Document displayof for Font.actual() and clarify Font.copy() (GH-153288) (GH-153331)
Explain the displayof argument of tkinter.font.Font.actual() and describe
what Font.copy() returns, including for a wrapped font description.
(cherry picked from commit fa5eafd19c3d395b4498e21b4e1b8faac2ebdb0a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-143921: Reject NUL, CR and LF in IMAP commands (GH-143922, GH-153067) (GH-153137) (GH-153287)
Combined backport of GH-143922, which rejected all control characters,
and GH-153067, which narrowed the check to NUL, CR and LF. Other
control characters are valid in quoted strings and are sent quoted.
[3.13] gh-83274: Don't crash when a Tcl interpreter is deallocated in the wrong thread (GH-152323) (GH-153278)
Deallocating the interpreter from a thread other than the one it was created
in ran Tcl_DeleteInterp() there, which makes Tcl abort the process
("Tcl_AsyncDelete: async handler deleted by the wrong thread").
Tkapp_Dealloc() now leaks the interpreter in that case and reports a
RuntimeWarning instead.