Skip to content

Commit 6828ce0

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.15] gh-68453: Fix IDLE -s together with -c, -r or - (GH-157592) (#157640)
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 52196a1 commit 6828ce0

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
@@ -1687,6 +1687,10 @@ def main():
16871687
if filename and os.path.isfile(filename):
16881688
shell.interp.execfile(filename)
16891689
if cmd or script:
1690+
# Let the startup file finish first: the command or script
1691+
# is to run after it, in its namespace (gh-68453).
1692+
while shell.executing:
1693+
root.update()
16901694
shell.interp.runcommand("""if 1:
16911695
import sys as _sys
16921696
_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)