Ensure restoration of sys.path in Context.load_module()

This commit is contained in:
Nikolaus Lieb 2015-07-25 18:27:31 +08:00
parent b22118a2de
commit 64f557a17e
1 changed files with 2 additions and 2 deletions

View File

@ -621,8 +621,8 @@ def load_module(path, encoding=None):
module_dir = os.path.dirname(path)
sys.path.insert(0, module_dir)
exec(compile(code, path, 'exec'), module.__dict__)
sys.path.remove(module_dir)
try : exec(compile(code, path, 'exec'), module.__dict__)
finally: sys.path.remove(module_dir)
cache_modules[path] = module