mirror of
https://github.com/cemu-project/idapython.git
synced 2024-11-28 03:54:18 +01:00
init.py: modules loaded by user scripts are now unloaded when the script finishes. No more reload() needed. Thanks to cbwhiz for the idea.
This commit is contained in:
parent
e1298031ac
commit
dd5273fee9
@ -55,7 +55,11 @@ def runscript(script):
|
||||
"""
|
||||
addscriptpath(script)
|
||||
watchdog.reset()
|
||||
# Save the argv, path, I/O and base modules for later cleanup
|
||||
argv = sys.argv
|
||||
path = sys.path
|
||||
stdio = [sys.stdin, sys.stdout, sys.stderr]
|
||||
basemodules = sys.modules.copy()
|
||||
sys.argv = [ script ]
|
||||
# Adjust the __file__ path in the globals we pass to the script
|
||||
g = globals()
|
||||
@ -66,8 +70,15 @@ def runscript(script):
|
||||
except:
|
||||
raise
|
||||
finally:
|
||||
# Restore the globals to the state before the script was run
|
||||
g['__file__'] = old__file__
|
||||
|
||||
sys.argv = argv
|
||||
sys.path = path
|
||||
sys.stdin, sys.stdout, sys.stderr = stdio
|
||||
# Clean up the modules loaded by the script
|
||||
for module in sys.modules.keys():
|
||||
if not module in basemodules:
|
||||
del(sys.modules[module])
|
||||
|
||||
def print_banner():
|
||||
version1 = "Python interpreter version %d.%d.%d %s (serial %d)" % sys.version_info
|
||||
|
Loading…
Reference in New Issue
Block a user