Decorate ttk.MenubuttonTest with add_configure_tests() and make
ttk.OptionMenuTest inherit it to cover the standard widget options.
(cherry picked from commit ce147129c1)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
[3.14] gh-151929: Get uptime on BSD/macOS in pythoninfo (#152189) (#152197)
gh-151929: Get uptime on BSD/macOS in pythoninfo (#152189)
* Check sysctlbyname() function and sys/sysctl.h header in
configure.
* Add _testcapi.uptime_bsd() function.
(cherry picked from commit b6d89edc4a)
(cherry picked from commit d25cf02a71)
[3.14] gh-151929: Get machine ID and uptime on Windows in pythoninfo (#152146) (#152187) (#152193)
[3.15] gh-151929: Get machine ID and uptime on Windows in pythoninfo (#152146) (#152187)
gh-151929: Get machine ID and uptime on Windows in pythoninfo (#152146)
* Replace "linux." prefix with "system." in pythoninfo.
* Add _winapi.GetTickCount64() function.
(cherry picked from commit f9910519af)
(cherry picked from commit ae4c2c126b)
(cherry picked from commit be65a38eb7)
gh-151929: Get boot ID, machine ID and uptime in test.pythoninfo (#152127)
GHA: Run test.pythoninfo on the "Cross build Linux" job.
(cherry picked from commit 3db3bba4d1)
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 c7faa6936e)
(cherry picked from commit 2d5187116b)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
tarfile reads a member's extended header (a GNU long name/link or a pax
header) with a single read sized by the header's size field:
buf = tarfile.fileobj.read(self._block(self.size))
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 da99711d37)
Co-authored-by: Shardul Deshpande <iamsharduld@users.noreply.github.com>
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 ee78d4323c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 124c7cd91b)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 1c5a11018a)
Co-authored-by: Rafael Weingartner-Ortner <38643099+RafaelWO@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
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.
(cherry picked from commit 4de5683f21)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
(cherry picked from commit 85fa295073)
Co-authored-by: Zang Peiyu <166481866+factnn@users.noreply.github.com>
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 e51b616eff)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 706238e764)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 aa71eb287f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 58fd9ec3cf)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Drive the drag-and-drop protocol (dnd_start and the DndHandler enter/
motion/commit, leave/cancel and end callbacks).
(cherry picked from commit 2a126a534b)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 a9db5cb52f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* 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 66cc048551)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 23793ac211)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 64fab74bd7)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 bb127c5a96)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 93b9e7666f)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The module-global 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.
Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e16f8)
(cherry picked from commit 7b55e9a93e)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add curses tests for panels, textpad, and window behavior
Extend test_curses with behavior-verifying tests that go beyond the
existing smoke tests:
* curses.panel stacking: new_panel/top/bottom/above/below ordering,
hide/show/hidden, move, replace and userptr round-trip.
* Real-window curses.textpad.Textbox: gather(), edit(), stripspaces,
insert mode and the Emacs-like editing commands (previously only
exercised through a MagicMock).
* Window output: addstr cursor advance and addnstr truncation,
insstr/insnstr shifting without cursor movement, and pad behavior
(instr, subpad cell sharing, the required 6-argument refresh()).
* Error handling: out-of-range coordinates raising curses.error and
bad character/string argument types.
(cherry picked from commit b4cfb992ed)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 4ac809e10b)
(cherry picked from commit 22c000eeb4)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>