Skip to content

Commit cf465da

Browse files
committedJan 31, 2016
tools/file_import: make sure sys.path is always restored
1 parent 0d18942 commit cf465da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

Diff for: ‎artiq/tools.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ def file_import(filename, prefix="file_import_"):
8585

8686
path = os.path.dirname(os.path.realpath(filename))
8787
sys.path.insert(0, path)
88-
89-
loader = importlib.machinery.SourceFileLoader(modname, filename)
90-
module = loader.load_module()
91-
92-
sys.path.remove(path)
88+
try:
89+
loader = importlib.machinery.SourceFileLoader(modname, filename)
90+
module = loader.load_module()
91+
finally:
92+
sys.path.remove(path)
9393

9494
return module
9595

0 commit comments

Comments
 (0)
Please sign in to comment.