summaryrefslogtreecommitdiff
path: root/Lib/idlelib/runscript.py
diff options
context:
space:
mode:
authorNgalim Siregar <ngalim.siregar@gmail.com>2019-07-21 22:37:28 +0700
committerTerry Jan Reedy <tjreedy@udel.edu>2019-07-21 11:37:28 -0400
commit35b87e6001bd991f625abe305951c77ddeb9a9c5 (patch)
tree03f4ffc0e8b45197b82fbe2affdf4b36a758b041 /Lib/idlelib/runscript.py
parent02c91f59b6f6e720a9e89635e00c55bcf7f932a8 (diff)
downloadcpython-git-35b87e6001bd991f625abe305951c77ddeb9a9c5.tar.gz
bpo-37627: Initialize IDLE Custom Run dialog with previous entries (#14870)
Repeat the command line arguments most recently entered before so the user can edit them.
Diffstat (limited to 'Lib/idlelib/runscript.py')
-rw-r--r--Lib/idlelib/runscript.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/idlelib/runscript.py b/Lib/idlelib/runscript.py
index b041e56fb8..f97cf528cc 100644
--- a/Lib/idlelib/runscript.py
+++ b/Lib/idlelib/runscript.py
@@ -39,6 +39,8 @@ class ScriptBinding:
# XXX This should be done differently
self.flist = self.editwin.flist
self.root = self.editwin.root
+ # cli_args is list of strings that extends sys.argv
+ self.cli_args = []
if macosx.isCocoaTk():
self.editwin.text_frame.bind('<<run-module-event-2>>', self._run_module_event)
@@ -137,10 +139,11 @@ class ScriptBinding:
return 'break'
if customize:
title = f"Customize {self.editwin.short_title()} Run"
- run_args = CustomRun(self.shell.text, title).result
+ run_args = CustomRun(self.shell.text, title,
+ cli_args=self.cli_args).result
if not run_args: # User cancelled.
return 'break'
- cli_args, restart = run_args if customize else ([], True)
+ self.cli_args, restart = run_args if customize else ([], True)
interp = self.shell.interp
if pyshell.use_subprocess and restart:
interp.restart_subprocess(
@@ -148,8 +151,8 @@ class ScriptBinding:
self.editwin._filename_to_unicode(filename))
dirname = os.path.dirname(filename)
argv = [filename]
- if cli_args:
- argv += cli_args
+ if self.cli_args:
+ argv += self.cli_args
interp.runcommand(f"""if 1:
__file__ = {filename!r}
import sys as _sys