Using PathFinder rather than find_loader to correctly handle paths

Using PathFinder rather than find_loader to correctly handle from ... import ...

Moved away from find_loader in favour of PathFinder also when using sys.path
This commit is contained in:
Aldo Stracquadanio
2013-03-25 19:30:58 +00:00
parent 07ec134bc9
commit 0b67a08e48
+4 -2
View File
@@ -22,9 +22,11 @@ def find_module_py33(string, path=None):
returning = (None, None, None) returning = (None, None, None)
importing = None importing = None
if path is not None: if path is not None:
importing = importlib.find_loader(string, path) importing = importlib.machinery.PathFinder.find_module(string, path)
else: else:
importing = importlib.find_loader(string) importing = importlib.machinery.PathFinder.find_module(string, sys.path)
if importing is None:
importing = importlib.find_loader(string)
if importing is None: if importing is None:
raise ImportError raise ImportError