Serhiy Storchaka [Wed, 24 Jun 2026 19:32:28 +0000 (22:32 +0300)]
[3.14] gh-86726: Improve the structure of the tkinter reference (GH-152109 (GH-152111) (GH-152116)
Add short group intros before each cluster of Misc methods.
Group the Tk and Toplevel classes in a new "Toplevel widgets" section, move
the Tcl() function to the module-level functions, and move the "File
handlers" section into the reference.
(cherry picked from commit c7faa6936e17630ec26d4e0438ae9b95561b7151)
(cherry picked from commit 2d5187116b526b3570c0010ba58f4066b6be468d)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
The size is taken from the archive and is not validated, so a ~512-byte
crafted file can claim several gigabytes (or, via base-256 encoding, far
more) and make read() pre-allocate that much memory -- on open/iterate,
before any extraction filter runs.
Read the extended-header data in bounded chunks instead, so an oversized
or truncated header can no longer force a huge allocation. The bytes
returned for valid archives are unchanged.
(cherry picked from commit da99711d37dba3413af05207ea8b12cb06041c0f)
[3.14] gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets (GH-152008) (GH-152050)
Spinbox, Scale and ttk.Spinbox format floating-point values according to
the LC_NUMERIC locale, but such values are always parsed with a period, so
a comma-decimal locale breaks DoubleVar.get().
(cherry picked from commit ee78d4323c174d0281fef5e04e965cda4c46eeb7)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.14] gh-126219: Fix crash in tkinter.Tk with non-BMP className on Tcl/Tk 8.x (GH-151980) (GH-152046)
Tcl 8.x crashes when title-casing a non-BMP character during Tk
initialization, so such a className is now rejected with a ValueError.
(cherry picked from commit 124c7cd91be8cff76d1eec0adef65991c23c4419)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Document where widget methods shadow inherited Misc, geometry-manager and
Wm methods, correct the inaccurate "size/bbox is an alias of
grid_size/grid_bbox" claims, and add "# overrides X" comments at the
definitions.
Also document the geometry-manager ambiguity: the short names forget, info,
slaves and propagate are defined by Pack, Place and Grid but
resolve to the pack variant.
Cross-reference the window-manager methods grid, forget and state with the
same-named grid geometry manager, Pack.forget and ttk.Widget.state.
[3.14] gh-151665: Fix inspect.signature() on type alias and type parameter evaluators (GH-151787) (#151880)
[3.15] gh-151665: Fix inspect.signature() on type alias and type parameter evaluators (GH-151787)
(cherry picked from commit 453714a2dc0d16e6e6b8cff70801dfc1284bf74d)
Zang Peiyu [Sun, 21 Jun 2026 16:39:36 +0000 (00:39 +0800)]
[3.14] gh-150484: Fix mock_open __exit__ with contextlib.ExitStack (GH-151829)
mock_open's _exit_side_effect had a fixed 3-arg signature, but
contextlib.ExitStack calls __exit__ with 4 args (self + 3 exc info).
Use *args to accept any number of arguments.
Verify the virtual events that widgets emit in response to user
interaction, driven by generated events: <<ListboxSelect>> (Listbox),
<<Increment>> and <<Decrement>> (ttk Spinbox), and <<TreeviewSelect>>,
<<TreeviewOpen>> and <<TreeviewClose>> (ttk Treeview).
(cherry picked from commit e51b616efff845ea2a7d312aa43d5f5100064d88)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter.filedialog (GH-151781) (GH-151796)
Exercise the native dialogs (Open, SaveAs and Directory) through the
_test_callback seam without opening them, and test the pure-Python
FileDialog selection, filter and ok/cancel logic without entering its
modal loop.
(cherry picked from commit 58fd9ec3cfe0d588db97eb98c0dc7fdb0256be76)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.14] gh-151678: Add interactive tests for tkinter.simpledialog (GH-151794) (GH-151803)
Drive the modal query dialogs with generated events to exercise the
<Return> and <Escape> key bindings and the value validation: accepting
an integer, float or string, cancelling, rejecting a non-numeric value
and rejecting a value outside the allowed range.
(cherry picked from commit 706238e764169dd36f918a0541adf9687cc3f296)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.14] gh-151678: Add tests for the remaining tkinter Misc, Wm and Text methods (GH-151782) (GH-151800)
Cover Misc.wait_variable and wait_window, tk_focusFollowsMouse,
selection_handle, the error paths of grab_set_global, send, the
X11-specific Wm methods iconposition, iconmask, iconwindow,
colormapwindows and manage/forget, and the Text.window_config alias and
deprecated yview_pickplace.
(cherry picked from commit aa71eb287f6d812e5270109acb9119c2ad0baef9)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter.dnd (GH-151780) (GH-151791)
Drive the drag-and-drop protocol (dnd_start and the DndHandler enter/
motion/commit, leave/cancel and end callbacks).
(cherry picked from commit 2a126a534b0253cf65fb6d06da0cce72eb2eaa23)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter.scrolledtext (GH-151753) (GH-151760)
Add a test for the ScrolledText widget, which had no tests: that it is
a Text widget held in a Frame with a Scrollbar, that Text methods work,
that the geometry manager methods are redirected to the frame while
configure is not, and that the scrollbar tracks the text view.
(cherry picked from commit a9db5cb52fefffc8fcdddc8e1c5f23222970825a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter font, image, variable, Misc and Wm methods (GH-151751) (GH-151755)
* font: copy(), the config alias, the displayof argument of measure and
metrics, and the errors raised for invalid options and a wrong number
of arguments;
* image: the cget method and the config alias, and the errors raised by
transparency_get and transparency_set;
* variable: that initialize is an alias of set and the deprecated trace
is an alias of trace_variable;
* Misc: tk_focusNext, tk_focusPrev, tk_strictMotif, tk_bisque and
option_readfile;
* Wm: wm_iconphoto.
(cherry picked from commit 66cc04855100c3865bd01adfe92a3a02dbc3a914)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter Misc, Wm and geometry manager methods (GH-151732) (GH-151738)
Cover previously-untested methods of the Misc, Wm, Pack, Place and Grid
classes:
* a new WinfoTest class for the winfo_* query methods (class, name,
parent, children, toplevel, visual and screen information, atoms,
pointer and screen coordinates, fpixels, containing, interps,
viewable), including the pre-existing winfo_rgb and winfo_pathname;
* in MiscTest: getint, getdouble, getvar, register, deletecommand,
option_add/get/clear, nametowidget, the focus_*, grab_* and
selection_own* methods, event_add/delete/info, and bell;
* in WmTest: title, geometry, minsize/maxsize, resizable, aspect, grid,
positionfrom/sizefrom, focusmodel, iconname, client/command,
overrideredirect, state (with withdraw and deiconify), frame, group,
protocol and transient;
* the short-named aliases of the grid_*, pack_* and place_* geometry
manager methods.
(cherry picked from commit 23793ac211371415eaf9491fef031f121969dfb3)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Serhiy Storchaka [Fri, 19 Jun 2026 12:08:22 +0000 (15:08 +0300)]
[3.14] gh-151693: Make the curses tests portable to other curses implementations (GH-151729) (GH-151731)
Guard the chgat() check (chgat() needs wchgat()) and stop assuming a
subpad shares the parent pad's cells (implementation-defined in X/Open).
(cherry picked from commit 64fab74bd7288bfa67cd7727452febdaafed4270)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.14] gh-151678: Add tests for the remaining tkinter widgets (GH-151687) (GH-151726)
Cover previously-untested methods of several widgets:
* Button, Checkbutton and Radiobutton: invoke, flash and toggle;
* Entry: delete, icursor and the select_* aliases;
* Spinbox: invoke, identify and scan;
* Scale and Scrollbar: identify, and Scrollbar fraction and delta;
* PanedWindow: panes, remove/forget, sash and proxy positioning,
identify, and adding panes with configuration options.
Also test that invoke does nothing for a disabled button and the
errors raised for invalid indices, coordinates, option names and values.
(cherry picked from commit 93b9e7666f4337e3cacfed6993568e4bec575e9b)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Serhiy Storchaka [Fri, 19 Jun 2026 09:49:22 +0000 (12:49 +0300)]
[3.14] gh-151695: Fix use-after-free of the curses screen encoding (GH-151696) (GH-151706)
The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call. That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.
[3.14] gh-151678: Add tests for tkinter.Canvas (GH-151683) (GH-151717)
Cover previously-untested Canvas methods in CanvasTest:
* item creation and types, bbox, coordinate conversion, move/scale,
find and addtag queries, tags, item configuration, stacking order,
text-item editing, selection, focus, scan and postscript;
* the create_arc, create_oval, create_bitmap, create_image,
create_text and create_window item creation methods, checking
coordinates, default and explicit options, valid enumerations and
rejection of invalid values;
* tag_bind() and tag_unbind(), checking the returned function id and
binding script, querying bound sequences, the add parameter, event
delivery to items via a tag, and removal of a single binding by id
or all bindings for a sequence.
(cherry picked from commit bb127c5a96a285f1f6b11261c1f0dc2b3c7f70ff)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter.Listbox (GH-151686) (GH-151713)
Cover previously-untested Listbox methods in ListboxTest: size, delete,
index resolution, nearest, see, activate, and the selection methods
(selection_set/clear/includes/anchor and their select_* aliases),
including the errors raised for invalid indices.
(cherry picked from commit cf3b3c11485a870d8e8c02579bed27a316838eb1)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.14] gh-151678: Add tests for tkinter.Menu (GH-151685) (GH-151710)
Cover previously-untested Menu methods in MenuTest: adding, inserting and
deleting items of every type, index resolution, invoking items, entry x/y
positions, and post/unpost/tk_popup mapping.
Also test per-entry configuration options and the errors raised for
invalid indices, entry types, option names and option values.
(cherry picked from commit ef5c32a40be50a33a9b7ac39ee64e6893bc22f60)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Serhiy Storchaka [Fri, 19 Jun 2026 09:08:14 +0000 (12:08 +0300)]
[3.14] gh-151678: Add tests for tkinter.Text (GH-151681) (GH-151705)
Cover previously-untested Text methods (indices, content, marks, tags,
undo/redo, dump, embedded images and windows, peers, and geometry) and
the tag, embedded-image and embedded-window configuration options.
(cherry picked from commit 4ac809e10bdb413d7dd8c7bab7e365b2b618ad91)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
[3.14] gh-86726: Document the full public API of tkinter (GH-151579) (GH-151650)
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: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-86726: Adjust tkinter docs for the 3.14 backport
Remove documentation of API added only in 3.15 (the grid_content/
pack_content/place_content aliases, Text.search_all, the search
nolinestop/strictlimits parameters and Event.user_data/detail), date the
wm_attributes positional-argument deprecation to 3.13, and update the
bundled Tcl/Tk version to 8.6.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Serhiy Storchaka [Thu, 18 Jun 2026 09:16:10 +0000 (12:16 +0300)]
[3.14] gh-151623: Improve curses documentation and docstrings (GH-151625) (GH-151629)
Fix errors and clarify the curses, curses.panel and curses.ascii docs
against X/Open Curses and ncurses, and sync the affected docstrings.
(cherry picked from commit 65afcdd8dfb3621ac696fce076e6282c76a04b2b)
[3.14] gh-120665: make unittest loaders avoid loading test cases that are abstract base classes (GH-120666) (#151600)
gh-120665: make unittest loaders avoid loading test cases that are abstract base classes (GH-120666)
(cherry picked from commit 5ad3c6dfbfe60a7f232e9604866c77ced24c4bfe)
[3.14] gh-151593: Use timeout on GitHub Action TSan jobs (GH-151594) (#151598)
gh-151593: Use timeout on GitHub Action TSan jobs (GH-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.
(cherry picked from commit 460dec26518df5aa262ded5a2ee4e94b8854b569)
Co-authored-by: Victor Stinner <vstinner@python.org>
Victor Stinner [Wed, 17 Jun 2026 09:41:24 +0000 (11:41 +0200)]
[3.14] gh-151546: Fix stack limits on musl (#151548) (#151583) (#151591)
[3.15] gh-151546: Fix stack limits on musl (#151548) (#151583)
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.
[3.14] gh-148260: Use at least 1 MiB stack size on musl (GH-149993) (#151586)
gh-148260: Use at least 1 MiB stack size on musl (GH-149993)
On Linux when Python is linked to the musl C library, use a thread
stack size of at least 1 MiB instead of musl default which is 128
kiB.
(cherry picked from commit df6c157e51430e8e7458012417c534ad8c33119f)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-151519: Check effective gid in `_test_all_chown_common` group-0 guard (GH-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.
[3.14] gh-151422: Don't link libffi into _ctypes_test.so (GH-151423) (#151517)
_ctypes_test doesn't use libffi directly, and linking it into the module
causes emscripten tests to fail.
(cherry picked from commit 8646385076ea4f6ef08682d8ef07a544d3b4ef30)
[3.14] gh-139837: Document attributes of objects recorded by warnings.catch_warnings (GH-139893) (#151473)
* gh-139837: Document attributes of objects recorded by warnings.catch_warnings (GH-139893)
(cherry picked from commit 47b7dc788c9bcf3d5ea69a2ea0aed3d5883647a8)
Co-authored-by: Aniket <148300120+Aniketsy@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* Apply suggestions from code review
[3.14] Skip test_highly_nested_objects_decoding during the PGO profile task. (GH-151460) (#151469)
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.
(cherry picked from commit e91f68ab40e25dc964afb872eb75873c8b1838d6)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Gregory P. Smith [Sat, 13 Jun 2026 09:13:13 +0000 (02:13 -0700)]
[3.14] gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268) (#151431)
* gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268)
(cherry picked from commit 3c00ebc2bbd902495b163def850bc931420209fc)
Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 4e8c9c6a5742659ca9f77719178802cce06a3507)
* Drop the abrupt-exit-code reporting from the 3.14 backport
Reporting the exit codes of processes that died without a known cause
is a new feature, not part of the gh-101267 bugfix. Keep only the
bugfix on 3.14: each failed future gets its own BrokenProcessPool
exception instead of one shared instance.
---------
Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>