def _runscript(self, filename):
# The script has to run in __main__ namespace (clear it)
import __main__
import imp
filename = os.path.abspath(filename)
__main__.__dict__.clear()
__main__.__dict__.update({"__name__" : "__main__",
"__file__" : filename,
"__builtins__": __builtins__,
"imp" : imp, # need for run
})
# avoid stopping before we reach the main script
self._wait_for_mainpyfile = 1
self.mainpyfile = self.canonic(filename)
self._user_requested_quit = 0
if sys.version_info>(3,0):
statement = 'imp.load_source("__main__", "%s")' % filename
else:
statement = 'execfile(%r)' % filename
self.startup()
self.run(statement)
评论列表
文章目录