[3.13] gh-151949: Fix Sphinx reference warnings in `Doc/library/lzma.rst` (GH-153878) (#154126)
* gh-151949: Fix Sphinx reference warnings in `Doc/library/lzma.rst` (GH-153878)
The lzma module constants (FORMAT_*, CHECK_*, PRESET_*, FILTER_*, MODE_*
and MF_*) were referenced with the :const: role throughout the module
documentation but were never defined as reference targets, producing
"reference target not found" warnings under nitpicky mode.
Document these public constants with .. data:: directives, following the
convention used by the signal, socket and ssl modules, so the existing
references resolve. The now-redundant inline descriptions of the format
and check constants are condensed into linked references.
(cherry picked from commit 1530b38c82f8f09c3c29b2829cd1d8c1db830761)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Stan Ulbrych <stan@python.org>
[3.13] gh-154435: Fix os.posix_fadvise() and os.posix_fallocate() on DragonFly BSD (GH-154436) (GH-154453)
They return -1 and set errno instead of returning the error number, so
OSError was raised with a meaningless error code.
(cherry picked from commit 08a0d10709f04cf03260e5e852381cecb1c531e1)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154427: Check the access time in UtimeTests only if it is stored (GH-154428) (GH-154439)
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.
(cherry picked from commit 6f8f97fe5246837b93e6c2f3525aa9f623ecd30b)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154416: Fix hanging test_tcflow on DragonFly BSD (GH-154417) (GH-154421)
TCIOFF and TCION transmit STOP and START characters, and closing the
pseudo-terminal waits until they are read. Discard them.
(cherry picked from commit b0c945a27e708419c6845234ef633ce3f7c4c41e)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154399: Fix venv activate.csh in a non-interactive shell (GH-154400) (GH-154410)
activate.csh saved the prompt unconditionally, but the prompt variable
only exists in interactive shells, and csh fails on an undefined
variable.
(cherry picked from commit 4448705d879ea41ea97114ef6c8215590913811a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-153741: Harden IDLE GUI tests for newer Tk and display scaling (GH-153742) (#154406)
gh-153741: Harden IDLE GUI tests for newer Tk and display scaling (GH-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().
(cherry picked from commit a2581ebc7a93ec573f64d3a5e29cbd9053de7a1f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.13] gh-154389: Do not use uuid_create() on OpenBSD (GH-154390) (GH-154393)
Like NetBSD, OpenBSD generates version 4 UUIDs in uuid_create(), so it
cannot be used for uuid.uuid1().
(cherry picked from commit c76fb912070389e0fbad3bf4eab066cd5da931b9)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154379: Fix test_epoll on Solaris (GH-154380) (GH-154384)
A non-blocking connect() can be completed immediately, and unregistering
a closed file descriptor succeeds on Solaris.
(cherry picked from commit b6abee522f1dbbba36cc306aa99ac22d1df5c454)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154366: Fix test_asyncio.test_sendfile timing out on DragonFly BSD (GH-154367) (GH-154373)
A 4 KiB receive buffer makes DragonFly defer every window update to the
delayed ACK timer, so each buffer worth of data costs 100 ms. Use a
larger socket buffer there; it is still small enough to pause the
protocol long before all data is sent.
(cherry picked from commit a6e1b836ec5055cbc8be477ca0c2df0cc12b8cb5)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154345: Fix test_posix_pty_functions() killing the worker on Solaris (GH-154346) (GH-154356)
Pushing the "ptem" STREAMS module makes a session leader without a
controlling terminal acquire the slave as one, so closing the file
descriptors sent SIGHUP to the session and killed the regrtest worker.
Disown it after the pushes, as os.openpty() does.
(cherry picked from commit f69f7fd526b6601a74ce0852c75466a183a86cea)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-154275: Do not crash on deeply nested `__parameters__` in `GenericAlias` (GH-154277) (#154340)
* [3.13] gh-154275: Do not crash on deeply nested `__parameters__` in `GenericAlias` (GH-154277)
(cherry picked from commit 1034e07b7d55642c3a46252e6b0a631c2df588d2)
[3.13] gh-154325: Skip test_add_file_after_2107() if the file system rejects the timestamp (GH-154328) (GH-154333)
Some file systems (UFS and ZFS on illumos) reject timestamps that do not
fit in 32 bits with EOVERFLOW instead of raising OverflowError.
(cherry picked from commit 63a2709b700d5532b8925caca5bc8b9437e7a1f3)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.13] gh-103925: Fix csv.Sniffer for a quoted field ending a CRLF line (GH-103926) (GH-154330)
"$" does not match before "\r" even in the MULTILINE mode, so such a
field was not found and the delimiter was guessed from character
frequencies instead, which could give a letter.
[3.13] gh-154307: Fix TemporaryDirectory cleanup on DragonFly BSD (GH-154309) (GH-154313)
On DragonFly BSD, removing a file or directory with the UF_NOUNLINK flag
fails with EISDIR (IsADirectoryError) instead of EPERM, so the cleanup did
not reset the flags. Handle IsADirectoryError the same as PermissionError.
(cherry picked from commit 1c1088b1da5a7484b7b04e90ccc47aa362e709eb)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.13] gh-154308: Clear file flags in os_helper.rmtree() (GH-154310) (GH-154316)
On BSD systems a test may leave behind files or directories with flags
such as UF_IMMUTABLE or UF_NOUNLINK set, which prevent the directory from
being modified or removed. Clear the flags before removing, so cleaning
up a temporary directory does not fail.
(cherry picked from commit 1f649fecb645d70b9c48268839e4177d8fe4e1d1)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.13] gh-154291: Fix socket.has_dualstack_ipv6() on DragonFly BSD (GH-154292) (GH-154301)
On DragonFly BSD setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) succeeds without
actually clearing the flag, so has_dualstack_ipv6() wrongly returned True.
Verify with getsockopt() that IPV6_V6ONLY was cleared.
(cherry picked from commit c7bbf040e721781be8f11a3b0716220835d4de2f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.13] gh-154283: Make threading.get_native_id() unique across processes on DragonFly (GH-154287) (GH-154298)
On DragonFly BSD lwp_gettid() is only unique within a process (the main
thread is always LWP 1), so combine it with the process id, like Solaris.
(cherry picked from commit 53597df11e2d9f01ade2529c147df24b49685878)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.13] gh-154289: Fix test_socket.testGetServBy on DragonFly (GH-154290) (GH-154296)
DragonFly lists "echo 4/ddp" before "echo 7/tcp" in /etc/services, like
FreeBSD, so avoid the "echo" service there too.
(cherry picked from commit 96059f9446510f594c4148d53bd1a4e3532af697)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[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>