From ee03611a8dd6ccb4ae408fbe2e43afda9d2da316 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 1 Jun 1999 18:18:27 +0000 Subject: [PATCH] Ensure sys.argv[0] is the script name on Run Script. --- Tools/idle/ScriptBinding.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tools/idle/ScriptBinding.py b/Tools/idle/ScriptBinding.py index 94a248f451e..9af8236ffd0 100644 --- a/Tools/idle/ScriptBinding.py +++ b/Tools/idle/ScriptBinding.py @@ -73,6 +73,9 @@ def run_script_event(self, event): flist = self.editwin.flist shell = flist.open_shell() interp = shell.interp + if (not sys.argv or + os.path.basename(sys.argv[0]) != os.path.basename(filename)): + sys.argv = [filename] interp.execfile(filename) def getfilename(self):