Skip to content

Commit 4ff7721

Browse files
serhiy-storchakaclaude
authored andcommitted
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 <storchaka@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 0ed896f commit 4ff7721

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎Lib/idlelib/pyshell.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,10 @@ def main():
16681668
if filename and os.path.isfile(filename):
16691669
shell.interp.execfile(filename)
16701670
if cmd or script:
1671+
# Let the startup file finish first: the command or script
1672+
# is to run after it, in its namespace (gh-68453).
1673+
while shell.executing:
1674+
root.update()
16711675
shell.interp.runcommand("""if 1:
16721676
import sys as _sys
16731677
_sys.argv = {!r}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix running IDLE with the -s option together with -c, -r or -: the command
2+
or script now runs after the startup file, without an error dialog and
3+
without restarting the shell.

0 commit comments

Comments
 (0)