Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-68453: Fix IDLE -s together with -c, -r or - (GH-157592)
The startup file runs in the subprocess asynchronously, so the command
or script was queued while it was still executing: an "Already
executing" dialog was shown, sys.argv was not set, and the subprocess
was restarted, discarding the startup file. Wait for the startup file
to finish first.
(cherry picked from commit 9cc3547)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
  • Loading branch information
2 people authored and miss-islington committed Sep 16, 2026
commit 5cc4c6c99d19ddb7693971f119b315214256096b
4 changes: 4 additions & 0 deletions Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,10 @@ def main():
if filename and os.path.isfile(filename):
shell.interp.execfile(filename)
if cmd or script:
# Let the startup file finish first: the command or script
# is to run after it, in its namespace (gh-68453).
while shell.executing:
root.update()
shell.interp.runcommand("""if 1:
import sys as _sys
_sys.argv = {!r}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix running IDLE with the -s option together with -c, -r or -: the command
or script now runs after the startup file, without an error dialog and
without restarting the shell.
Loading