Skip curses tests when scr_dump()/is_keypad() are unavailable (GH-153866)
test_scr_dump() and test_state_getters() errored instead of skipping on
builds without scr_dump(), is_keypad() or is_leaveok() (e.g. some narrow
ncurses, NetBSD, PDCurses).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153844: Support AST input in symtable.symtable() (GH-153845)
The builtin compile() accepts an AST object since Python 2.6, but
symtable.symtable() only accepted str and bytes, although the
implementation builds the symbol table from an AST anyway. Accept an
AST object as well: convert it for the requested compile type, validate
it, honor future statements found in the tree, and build the symbol
table the same way the compiler does.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
gh-153395: Accept curses.complexchar in curses.ascii predicates and conversions (GH-153396)
The curses.ascii predicates and the ctrl() and unctrl() functions now accept
a curses.complexchar, classifying it by its single character. ctrl() now
returns a non-ASCII argument unchanged instead of masking it to a control
character.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153521: Support structured arguments in imaplib commands (GH-153522)
Command methods now accept a structured *message_set* (an integer, or a
sequence of integers, (start, stop) ranges and range objects) and lists of
flags or other atoms in place of preformatted parenthesized strings.
The search, fetch, sort, thread and uid methods gain a keyword-only *params*
argument that substitutes and quotes '?' placeholders in their value-bearing
arguments, in the manner of sqlite3 parameter substitution.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: R. David Murray <rdmurray@bitdance.com>
Lucas Colley [Fri, 17 Jul 2026 06:32:29 +0000 (08:32 +0200)]
gh-152384: pixi-packages: use `flags` to define variants (#152385)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Isuru Fernando <isuruf@gmail.com> Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
gh-153550: Modernize the older prose sections of the tkinter documentation (GH-153647)
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.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-153716: Harden ttk/tkinter GUI tests against display scaling (GH-153717)
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.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-102960: Make frames weak-referenceable (#152838)
Add an explicit f_weakreflist field to the frame object, following the
same pattern as generators and coroutines, including free-threading-safe
weakref clearing via FT_CLEAR_WEAKREFS() in frame_dealloc().
Py_TPFLAGS_MANAGED_WEAKREF is not used because static builtin types
must not carry it (see init_static_type()) and the pre-header would
cost two extra words per frame instead of one.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gh-153631: Move to `macos-26` runner for iOS (#153632)
Switches iOS CI to use the macos-26 runner, and 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.
gh-153513: Remove obsolete Tk version guards in tkinter tests (GH-153615)
Since gh-153513, _tkinter returns int, float and pixel objects for the
corresponding Tcl object types on all Tk versions. The tests for the
Text "tabs" and ttk "padding" options therefore no longer need to expect
string tuples on Tk older than 8.6.14.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Matt Van Horn [Sat, 11 Jul 2026 15:57:37 +0000 (08:57 -0700)]
gh-145694: Update tutorial indentation guidance for PyREPL auto-indent (#145725)
The tutorial stated users must manually type tabs/spaces at the interactive
prompt, which is no longer accurate since the PyREPL in Python 3.13+
auto-indents after compound statement headers. Updated to mention both
the default REPL behavior and the basic REPL fallback.
gh-126877: Fix the configure check for Tcl/Tk with optimizing compilers (GH-153543)
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.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Rename the first parameter of paneconfigure() (and its paneconfig alias)
from 'tagOrId' to 'child', for consistency with add(), remove() and
panecget() -- PanedWindow panes are child widgets, not tagged items. The
old 'tagOrId' keyword still works but raises DeprecationWarning.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Opening several files at once is error-prone, and the returned list
cannot be used in a "with" statement. Iterate over the names returned
by askopenfilenames() and open them one by one instead.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gh-153259: Add tkinter.systray -- system tray icon and notifications (GH-153260)
Add the tkinter.systray module with the SysTrayIcon class wrapping the
"tk systray" command and the notify() function wrapping "tk sysnotify"
(Tk 8.7/9.0 and newer).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153256: Add tk_print() methods to tkinter Canvas and Text (GH-153257)
The native print dialog (the "tk print" command, Tk 8.7/9.0+) only
supports canvas and text widgets, so expose it as a method of Canvas
and Text rather than of Misc.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153333: Read tkinter profile scripts with the source file's encoding (GH-153334)
Tk.readprofile ran the user's ~/.CLASS.py and ~/.BASE.py scripts with
exec(open(path).read()), decoding them with the locale encoding. Read
them in binary mode so exec() honors each script's own coding cookie.
gh-151914: Reorganize the curses entries in What's New in Python 3.16 (GH-153397)
Order the curses entries from the most important and general to the more
specialized: wide-character and complexchar/complexstr support first, then
multiple-terminal support, attributes and colors, screen and window management,
input handling, and finally introspection. The curses.textpad.Textbox entry,
belonging to a separate submodule, moves to the end.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-59396: Add use_ttk parameter to tkinter ScrolledText (GH-153119)
ScrolledText gained a keyword-only use_ttk parameter to build the
surrounding frame and the vertical scroll bar from the themed
tkinter.ttk widgets instead of the classic tkinter widgets. The
classic widgets remain the default.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-116946: Implement the GC protocol for _tkinter tkapp and tktimertoken (GH-152310)
The _tkinter.tkapp and _tkinter.tktimertoken types never implemented the
garbage collector protocol, so reference cycles through an interpreter's
trace function or a timer handler's callback could not be collected.
A pending timer is kept alive by the Tcl event loop, which fires it even
after the Python token is dropped, so it is treated as a GC root (only its
callback is traversed) and collecting it never cancels a live timer. The
GC slots use a plain cast rather than the type-checking macro, since the
collector may visit a surviving object at shutdown after module clearing
has reset the global type pointers. Deallocation cancels any pending timer
so its callback cannot run on freed memory.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-143070: Use "+" instead of "!" in automatically generated tkinter widget names (GH-151975)
The "!" prefix has a special meaning in the tag expressions of the
canvas and text widgets ("!", "&&", "||", "^" and parentheses), so an
automatically generated widget name could not be used as a tag. "+" has
no special meaning there, nor in option database patterns or Tcl lists,
and a user is very unlikely to start an explicit name with it.
gh-153513: Remove redundant conversions in tkinter tests (GH-153520)
Now that index, window, parsedVarName and pixel options are returned as
str, int or float, drop the str()/int()/float() wrappers that only
worked around Tcl_Obj results. The generated test_configure_* tests now
also check that int- and float-valued options are returned as numbers.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153494: Encode imaplib search criteria to the declared CHARSET (GH-153495)
IMAP4.search(), sort(), thread() and the uid SORT/THREAD variants now encode
str search criteria to the declared charset, so international search text can
be passed as ordinary str. A criterion passed as bytes is sent unchanged, for
use with a charset that Python has no codec for.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gh-153513: Return str and numbers for more Tcl object types in _tkinter (GH-153514)
FromObj() now returns str for the "index", "window", "nsName" and
"parsedVarName" object types, whose internal representation is only a
context-bound lookup with nothing worth preserving in a Tcl_Obj. An
"index" value is one of a small fixed set of enumeration keywords, so
its str is interned.
A "pixel" screen distance with no unit suffix is screen independent and
is now returned as an int or float. A distance with an m/c/i/p suffix
needs a Tk_Window to be resolved and is kept as a Tcl_Obj, as are the
"dict" and the resource types "color", "border", "font" and "cursor".
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-151669: Normalize symlink targets in tarfile.TarFile.gettarinfo() (GH-151671)
This applies a normalization when creating members vrom the filesystem,
complementary to the one added to tarfile.TarFile.extract() in gh-138309
that does it in the other direction.
This solves an issue with round-tripping through the filesystem.
gh-153502: Add uid parameter to imaplib command methods (GH-153508)
Add a keyword-only uid=False argument to IMAP4.copy(), move(), fetch(),
store(), search(), sort(), thread() and expunge(), selecting the UID
variant of the command as a shorthand for uid(). expunge() also gains
an optional message_set argument, required for UID EXPUNGE.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-153062: Fix a crash iterating itertools.tee on the free-threaded build (gh-153063)
itertools.tee branches share a linked list of teedataobject cells. On the free-threaded build, iterating one branch from multiple threads, or iterating sibling branches concurrently, raced on the shared cells and each branch's position, corrupting refcounts and crashing.
Lock each teedataobject while reading, extending, or clearing it, and snapshot each branch's position under the tee object's own lock, revalidating before advancing, so the two locks are never nested. Concurrent iteration of one tee is undefined and may raise RuntimeError as documented, but no longer crashes.
The free-threading snapshot and revalidation add per-element overhead on the default build, where the GIL already serializes access. Guard that path under Py_GIL_DISABLED so the default build keeps the original iteration and the free-threaded path is unchanged.
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Victor Stinner [Thu, 9 Jul 2026 23:29:53 +0000 (01:29 +0200)]
gh-152132: Enhance Py_RunMain() and fix bugs (#153461)
* 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.
* Add pymain_error() and pyrun_error(): write the error message to
sys.stderr instead of the C stream stderr.
* Convert _PyPathConfig_UpdateGlobal() PyStatus error to an
exception.
* Simplify pymain_run_startup(): avoid strerror() which is decoded
from the wrong encoding. Instead display the exception, Py_fopen()
raises an OSError with the path object (and can raise other exceptions).
* Add pymain_set_path0() function.
* Add _PySys_FormatV() function.
Victor Stinner [Thu, 9 Jul 2026 18:28:15 +0000 (20:28 +0200)]
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.
gh-152997: Support system locale encodings via an iconv-based codec (GH-153001)
Where the C library provides iconv(), the codecs module now exposes every
encoding iconv() knows but Python has no built-in codec for -- the POSIX
counterpart of the Windows code-page support. Use it by name (e.g.
"cp1133"), or with an "iconv:" prefix to force it over a built-in codec.
The codec is a last-resort search function and never shadows a built-in.
Both directions pivot through native-endian UTF-32, keeping one input unit
per code point so error handlers get the exact string position.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>