mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Closes issue #18698: ensure importlib.reload() returns the module out of sys.modules.
This commit is contained in:
parent
01dbca0b06
commit
8e4554027b
3 changed files with 21 additions and 1 deletions
|
@ -118,7 +118,9 @@ def reload(module):
|
|||
if parent_name and parent_name not in sys.modules:
|
||||
msg = "parent {!r} not in sys.modules"
|
||||
raise ImportError(msg.format(parent_name), name=parent_name)
|
||||
return module.__loader__.load_module(name)
|
||||
module.__loader__.load_module(name)
|
||||
# The module may have replaced itself in sys.modules!
|
||||
return sys.modules[module.__name__]
|
||||
finally:
|
||||
try:
|
||||
del _RELOADING[name]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue