gh-152026: Track mark-saving contexts with a counter (GH-153160)
Replace the state->repeat checks that guard mark saving and restoring
with an explicit save_marks counter maintained where repeat and
possessive contexts are entered and left. Each push is now paired
with a pop decided by the same condition.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Add a wrapper for the IMAP ID command (RFC 2971). It takes a mapping
of field names to values and returns the server identification
information from the untagged ID response.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
gh-143921: Narrow the control character check in imaplib commands (GH-153067)
Only NUL, CR and LF are rejected now. Other control characters are
valid in quoted strings and can occur in mailbox names returned by
the server, so they are now accepted and sent quoted.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
gh-43699: Defer the drag cursor in tkinter.dnd until the pointer moves (GH-152371)
The drag cursor is now changed only once the pointer starts moving past
a small threshold rather than on the initial button press, so that a
plain click no longer flashes it.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-59396: Use themed widgets in tkinter.filedialog (GH-152036)
The FileDialog, LoadFileDialog and SaveFileDialog dialogs are now built from
the themed tkinter.ttk widgets by default instead of the classic tkinter
widgets, and gained a use_ttk parameter that selects between the classic Tk
widgets and the themed ttk widgets.
They were also brought closer to the native Tk file dialog: the buttons and
field labels gained Alt key accelerators, the default ring follows the keyboard
focus, the Escape key cancels the dialog, the focus traverses the widgets in
their visual order, and the directory and file lists gained a horizontal
scrollbar and type-ahead selection. The dialog is now transient and centered
over its parent, and the SaveFileDialog overwrite confirmation uses a themed
message box.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gh-79638: Restore "Treat an unreachable robots.txt as disallow all" (GH-152525)
This change was accidentally reverted by f0daba1652c (gh-106693,
GH-149514), which only intended to revert the ob_sval change.
The tests were already restored by GH-149569.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-75952: Document negative offsets in tkinter geometry strings (GH-152531)
Tk geometry strings can contain a negative offset (e.g. 200x100+-9+-8)
when a window edge is positioned beyond the corresponding screen edge.
Note this in the geometry() and winfo_geometry() documentation.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
A Tk variable wrapper unsets its Tcl variable when garbage collected, so a
reference must be kept while a widget uses it. Otherwise Tk recreates the Tcl
variable but never unsets it again, leaking it.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-69134: Wait until mapped in SimpleDialog keyboard tests (GH-152690)
The SimpleDialog keyboard tests generate key events after focus_force(),
which on Windows are dropped until the toplevel is mapped, so they could
fail intermittently (seen on the Windows10 buildbot as
test_return_no_default). Wait until the window is mapped in each of
these tests, as GH-152599 did for the other keyboard tests.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-151819: Clarify the conditional-pattern email example in re docs (GH-153072)
The example pattern does not fail to match '<user@host.com' outright --
re.search finds 'user@host.com' in it; it only fails to match the
whole string. Reword to say so.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-40038: Quote imaplib command arguments when necessary (GH-152703)
Argument quoting was inadvertently disabled when imaplib was ported to
Python 3 (bpo-1210 commented out the ``_checkquote()`` call, bpo-9638
then removed it), so since Python 3.0 commands failed for arguments
containing protocol-sensitive characters, such as a space in a mailbox
name.
Quoting is restored and reimplemented per the RFC 3501 grammar, so that
arguments that need quoting are escaped and quoted, while flags, sequence
sets and list wildcards are left intact.
For backward compatibility, an argument already enclosed in double quotes
is left unchanged, so code that quotes arguments itself keeps working.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-153030: Fix quadratic complexity in incremental parsing in HTMLParser (GH-153031)
When an unterminated construct (e.g. a tag or comment) spanned many
feed() calls, rescanning the growing buffer and concatenating new data
onto it were both quadratic. New data is now accumulated in a list and
only joined and parsed once enough has piled up.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gh-83386: Enable test_hang_gh83386 for ProcessPoolExecutor (GH-152976)
The hang this test guards against (interpreter exit after
shutdown(wait=False) with running futures) was fixed for
ProcessPoolExecutor by the executor management rewrite years ago, but
the test still skipped it citing the issue. The skip also hid a latent
NameError in the subprocess template, which only selects a start method
in the process pool variants; rewrite it to use the same
mp_context=get_context() shape as the sibling templates. Remove a stale
comment claiming ProcessPoolExecutor often hangs with wait=False.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading (gh-151768)
In free-threading builds, concurrent calls to sys.getdlopenflags() and
sys.setdlopenflags() race on interp->imports.dlopenflags. Fix by
using FT_ATOMIC_LOAD_INT_RELAXED / FT_ATOMIC_STORE_INT_RELAXED in
_PyImport_GetDLOpenFlags and _PyImport_SetDLOpenFlags, consistent with
how analogous interpreter-state integer fields (lazy_imports_mode,
pystats_enabled) are protected.
Relaxed ordering is correct here: dlopenflags is a standalone config
integer with no ordering relationship to other memory.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Henry Schreiner [Fri, 3 Jul 2026 18:11:16 +0000 (14:11 -0400)]
gh-150579: use lazy imports for concurrent.futures (GH-150585)
This module has a manual lazy import hack using `__getattr__`. Now that lazy imports exist and cannot be disabled, this could use lazy imports instead.
Key differences: this will now show up in sys.lazy_modules when accessed. Error messages should be a bit better without the wrapper `__getattr__` involved. That's the only differences I can think of.
Signed-off-by: Henry Schreiner <henryfs@princeton.edu> Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-115634: Fix ProcessPoolExecutor deadlock with max_tasks_per_child (GH-140900)
The idle worker semaphore counts task completions, not idle workers, so
it can hold a stale token released by a worker that later exited upon
reaching its max_tasks_per_child limit. The worker replacement path
consumed such tokens and skipped spawning a replacement, deadlocking
the remaining queued tasks once no workers were left.
Replace dead workers based on len(self._processes) without consulting
the semaphore. The submit() path is unchanged, preserving on-demand
spawning and idle worker reuse.
Replace the documentation note added in GH-140897 with a versionchanged
entry now that the bug is fixed.
gh-144067: Document terminal leak when initscr() follows setupterm() (GH-152624)
The curses library keeps a single current terminal: calling initscr()
or newterm() after setupterm() abandons the terminal that setupterm()
allocated without freeing it. This cannot be fixed safely in code
(freeing the terminal would break the capsule API and pending terminfo
queries), so document the behavior, with a cross-reference from
initscr() and newterm().
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
gh-152789: Skip curses tests needing newterm() on ncurses before 6.5 (GH-152880)
ncurses before 6.5 can crash on repeated newterm(). Fall back to initscr()
in TestCurses and skip ScreenTests and SLKTests, which need several screens.
The shared initscr() screen also needs its rendition and background reset
between tests.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Victor Stinner [Thu, 2 Jul 2026 13:00:51 +0000 (15:00 +0200)]
gh-152680: Detect virtualization on Windows in pythoninfo (#152824)
Use WMI to detect virtualization on Windows.
Replace wmic command with _wmi module to get the operating system caption and
version.
The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242
For example, it's no longer installed in Windows images on GitHub
Action.
Fix also run_command(): no longer try to spawn a subprocess if the
platform doesn't support subprocess. It avoids logging run_command()
errors.
gh-88574: Skip a spurious blank line after a literal in imaplib (GH-152751)
Some IMAP servers send an extra blank line after the data of a literal.
imaplib mistook it for the response trailer and failed on the next
command. Such a blank line is now skipped.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-66335: Add tests for imaplib command methods (GH-152872)
Add coverage tests for the IMAP4 command methods and their UID variants
(SELECT, CREATE, COPY, STORE, FETCH, SEARCH, SORT, THREAD, DELETE,
RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, the ACL and quota
commands, ANNOTATION, PROXYAUTH and ENABLE), plus test helpers
(splitargs, parse_sequence_set, make_simple_handler) and per-command
argument capture in the test server.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-108280: Give a meaningful error for an invalid imaplib greeting (GH-152768)
Connecting to a server that does not send a valid IMAP4 greeting, such as
a POP3 server answering on the IMAP port, failed with the unhelpful
"imaplib.IMAP4.error: None". A meaningful message is now raised instead.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-63121: Refresh imaplib capabilities on state changes (GH-152752)
imaplib fetched the server capabilities only once, at connection time.
They are now also refreshed after a successful LOGIN or AUTHENTICATE,
from the CAPABILITY response the server sent or, if it sent none, by
querying it. This lets methods such as enable() see capabilities added
after login, for example ENABLE on Gmail (gh-103451).
Capabilities advertised in the server greeting are now used too, saving
a redundant CAPABILITY command.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gh-82183: Do not restart the busy IDLE shell when running without restart (#152745)
"Run... Customized" with "Restart shell" unchecked restarted the shell
anyway when it was busy executing code, killing any pending input. It now
reports that the shell is executing just once, not twice, and does not run.
gh-134300: Remove idlelib from the path of the IDLE user process (#152739)
The idlelib directory ends up on sys.path when idle.py is run as a script,
and it was passed to the user process, where it let user code import
idlelib submodules as top-level modules, such as "import help".
gh-71956: Fix IDLE Replace All searching up without wrap around (#152737)
When the search direction is "Up" and "Wrap around" is off, Replace All
replaced only the first match above the current position (and all matches
below it). It now replaces all matches from the start of the text down to
the current position, consistently with the "Up" direction.
gh-66331: Set correct WM_CLASS on X11 for IDLE windows (#152733)
Set the WM_CLASS of IDLE's long-lived windows (window-list windows and
the stack viewers) to "Idle" instead of the default "Toplevel", so that
window managers group and label them correctly.
Bump the `actions/{github-script,checkout}` and `j178/prek-action` actions (#152760)
Bumps the actions group with 3 updates: [actions/github-script](https://github.com/actions/github-script), [actions/checkout](https://github.com/actions/checkout) and [j178/prek-action](https://github.com/j178/prek-action).