Issue #13591: import_module potentially imports a module twice.

This commit is contained in:
Meador Inge 2011-12-14 22:27:28 -06:00
commit d7afeeeb8d
4 changed files with 29 additions and 2 deletions

View file

@ -837,7 +837,9 @@ def _gcd_import(name, package=None, level=0):
for finder in meta_path:
loader = finder.find_module(name, path)
if loader is not None:
loader.load_module(name)
# The parent import may have already imported this module.
if name not in sys.modules:
loader.load_module(name)
break
else:
raise ImportError(_ERR_MSG.format(name))