From 9876c4ffa75b5d8bf0da54822d12654ff2113f33 Mon Sep 17 00:00:00 2001 From: "gergely.erdelyi" Date: Sun, 19 Jul 2009 17:22:21 +0000 Subject: [PATCH] init.py: __file__ path is properly set for scripts run with Alt-9 --- python/init.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/init.py b/python/init.py index c81483d..352980a 100644 --- a/python/init.py +++ b/python/init.py @@ -59,8 +59,17 @@ def runscript(script): watchdog.reset() argv = sys.argv sys.argv = [ script ] - execfile(script, globals()) - sys.argv = argv + # Adjust the __file__ path in the globals we pass to the script + g = globals() + old__file__ = g['__file__'] + g['__file__'] = script + try: + execfile(script, g) + except: + raise + finally: + g['__file__'] = old__file__ + def print_banner(): version1 = "Python interpreter version %d.%d.%d %s (serial %d)" % sys.version_info