@@ -39,6 +39,8 @@ def __init__(self, editwin):
3939 # XXX This should be done differently
4040 self .flist = self .editwin .flist
4141 self .root = self .editwin .root
42+ # cli_args is list of strings that extends sys.argv
43+ self .cli_args = []
4244
4345 if macosx .isCocoaTk ():
4446 self .editwin .text_frame .bind ('<<run-module-event-2>>' , self ._run_module_event )
@@ -137,19 +139,20 @@ def _run_module_event(self, event, *, customize=False):
137139 return 'break'
138140 if customize :
139141 title = f"Customize { self .editwin .short_title ()} Run"
140- run_args = CustomRun (self .shell .text , title ).result
142+ run_args = CustomRun (self .shell .text , title ,
143+ cli_args = self .cli_args ).result
141144 if not run_args : # User cancelled.
142145 return 'break'
143- cli_args , restart = run_args if customize else ([], True )
146+ self . cli_args , restart = run_args if customize else ([], True )
144147 interp = self .shell .interp
145148 if pyshell .use_subprocess and restart :
146149 interp .restart_subprocess (
147150 with_cwd = False , filename =
148151 self .editwin ._filename_to_unicode (filename ))
149152 dirname = os .path .dirname (filename )
150153 argv = [filename ]
151- if cli_args :
152- argv += cli_args
154+ if self . cli_args :
155+ argv += self . cli_args
153156 interp .runcommand (f"""if 1:
154157 __file__ = { filename !r}
155158 import sys as _sys
0 commit comments