fix ModuleManager.find_module() - don't set path until it's actually found

This commit is contained in:
jesopo 2019-12-10 11:08:44 +00:00
parent 671e259ada
commit a3bde5e682

View file

@ -159,16 +159,15 @@ class ModuleManager(object):
paths = self._module_paths(name) paths = self._module_paths(name)
path = None path = None
for path in paths: for possible_path in paths:
if os.path.isdir(path): if os.path.isdir(possible_path):
type = ModuleType.DIRECTORY type = ModuleType.DIRECTORY
path = os.path.join(path, "__init__.py") possible_path = os.path.join(possible_path, "__init__.py")
else: else:
possible_path = "%s.py" % path possible_path = "%s.py" % possible_path
if os.path.isfile(possible_path): if os.path.isfile(possible_path):
path = possible_path path = possible_path
if path:
break break
if not path: if not path: