mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
Issue #13591: import_module potentially imports a module twice.
This commit is contained in:
commit
d7afeeeb8d
4 changed files with 29 additions and 2 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue