Merge pull request #20843 from matdrapeau/16556/ImportError_custom_dep

Adding current module directory to the sys.path when loading a module
This commit is contained in:
Thomas S Hatch 2015-02-20 11:20:32 -07:00
commit 90994722f0

View File

@ -895,6 +895,7 @@ class LazyLoader(salt.utils.lazy.LazyDict):
fpath, suffix = self.file_mapping[name]
self.loaded_files.append(name)
try:
sys.path.append(os.path.dirname(fpath))
if suffix == '.pyx':
mod = self.pyximport.load_module(name, fpath, tempfile.gettempdir())
else:
@ -948,6 +949,8 @@ class LazyLoader(salt.utils.lazy.LazyDict):
exc_info=True
)
return mod
finally:
sys.path.pop()
if hasattr(mod, '__opts__'):
mod.__opts__.update(self.opts)