issue #18698: ensure importlib.reload() returns the module out of sys.modules.

This commit is contained in:
Eric Snow 2013-08-14 18:03:34 -06:00
parent e76c0393a8
commit 7491f1726b
3 changed files with 22 additions and 1 deletions

View file

@ -268,7 +268,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]