Skip to content

Commit

Permalink
tools/file_import: make sure sys.path is always restored
Browse files Browse the repository at this point in the history
sbourdeauducq committed Jan 31, 2016
1 parent 0d18942 commit cf465da
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions artiq/tools.py
Original file line number Diff line number Diff line change
@@ -85,11 +85,11 @@ def file_import(filename, prefix="file_import_"):

path = os.path.dirname(os.path.realpath(filename))
sys.path.insert(0, path)

loader = importlib.machinery.SourceFileLoader(modname, filename)
module = loader.load_module()

sys.path.remove(path)
try:
loader = importlib.machinery.SourceFileLoader(modname, filename)
module = loader.load_module()
finally:
sys.path.remove(path)

return module

0 comments on commit cf465da

Please sign in to comment.