diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 6e57e306a3678d9..4965c14fd2a4ced 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -1674,6 +1674,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} diff --git a/Misc/NEWS.d/next/IDLE/2026-09-15-21-20-04.gh-issue-68453.hlxbog.rst b/Misc/NEWS.d/next/IDLE/2026-09-15-21-20-04.gh-issue-68453.hlxbog.rst new file mode 100644 index 000000000000000..4d8cfc1dbc6574a --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2026-09-15-21-20-04.gh-issue-68453.hlxbog.rst @@ -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.