Clean up find_module_py33 loader finding

This commit is contained in:
Laurens Van Houtven
2013-06-20 22:05:08 +02:00
parent f171617766
commit 1b0822743c

View File

@@ -16,17 +16,10 @@ is_py33 = sys.hexversion >= 0x03030000
def find_module_py33(string, path=None):
mod_info = (None, None, None)
loader = None
if path is not None:
# Check for the module in the specidied path
loader = importlib.machinery.PathFinder.find_module(string, path)
else:
# Check for the module in sys.path
loader = importlib.machinery.PathFinder.find_module(string, sys.path)
if loader is None:
# Fallback to find builtins
loader = importlib.find_loader(string)
loader = importlib.machinery.PathFinder.find_module(string, path)
if loader is None and path is None: # Fallback to find builtins
loader = importlib.find_loader(string)
if loader is None:
raise ImportError("Couldn't find a loader for {0}".format(string))