From c725b6624b5d2cc3de33a808f91f215e7107e91b Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 3 Sep 2012 14:07:35 +0200 Subject: [PATCH] fixed a sys.path issue disscussed in github issue #7 --- builtin.py | 2 +- imports.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/builtin.py b/builtin.py index ce467c20..da3d8be9 100644 --- a/builtin.py +++ b/builtin.py @@ -102,7 +102,7 @@ class Parser(CachedModule): content = {} exec_function('import %s as module' % name, content) self._module = content['module'] - self.sys_path, sys.path = sys.path, temp + sys.path = temp if path: self.sys_path.pop(0) diff --git a/imports.py b/imports.py index 8450767f..35ab9db5 100644 --- a/imports.py +++ b/imports.py @@ -140,7 +140,11 @@ class ImportPath(object): # Override the sys.path. It works only good that way. # Injecting the path directly into `find_module` did not work. sys.path, temp = builtin.module_find_path, sys.path - i = imp.find_module(string) + try: + i = imp.find_module(string) + except: + sys.path = temp + raise sys.path = temp return i