summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2013-08-15 00:11:09 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2013-08-15 00:11:09 (GMT)
commit8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6 (patch)
tree7b33f885875ae3fe783d6599e1010cfaefc0ad27 /Lib/importlib
parent01dbca0b0626c7846d917883e6b7b5667c4fe6ba (diff)
downloadcpython-8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6.zip
cpython-8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6.tar.gz
cpython-8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6.tar.bz2
Closes issue #18698: ensure importlib.reload() returns the module out of sys.modules.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index 6732977..69ca9ce 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -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]