init.py: __file__ path is properly set for scripts run with Alt-9

This commit is contained in:
gergely.erdelyi 2009-07-19 17:22:21 +00:00
parent b0d8723ccb
commit 9876c4ffa7

View File

@ -59,8 +59,17 @@ def runscript(script):
watchdog.reset() watchdog.reset()
argv = sys.argv argv = sys.argv
sys.argv = [ script ] sys.argv = [ script ]
execfile(script, globals()) # Adjust the __file__ path in the globals we pass to the script
sys.argv = argv g = globals()
old__file__ = g['__file__']
g['__file__'] = script
try:
execfile(script, g)
except:
raise
finally:
g['__file__'] = old__file__
def print_banner(): def print_banner():
version1 = "Python interpreter version %d.%d.%d %s (serial %d)" % sys.version_info version1 = "Python interpreter version %d.%d.%d %s (serial %d)" % sys.version_info