summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2011-12-15 04:23:46 (GMT)
committerMeador Inge <meadori@gmail.com>2011-12-15 04:23:46 (GMT)
commit416f12ddb3b7d780bb75563414b88b32c0cf7e67 (patch)
treecbe4c2d385714638e0bda1c2d60289dc3182f5a4 /Lib/importlib/_bootstrap.py
parent061c0289af979213984046c0f7570192063ab319 (diff)
downloadcpython-416f12ddb3b7d780bb75563414b88b32c0cf7e67.zip
cpython-416f12ddb3b7d780bb75563414b88b32c0cf7e67.tar.gz
cpython-416f12ddb3b7d780bb75563414b88b32c0cf7e67.tar.bz2
Issue #13591: import_module potentially imports a module twice.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 425b8bf..90eb1a7 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -816,7 +816,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))