summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2013-11-01 04:22:15 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2013-11-01 04:22:15 (GMT)
commitcdf601281f5909b4b7c6e1f10f3a80d3c216cdc3 (patch)
tree2bea84bd69350b853084377ab70bd17254bd4010 /Lib/importlib/_bootstrap.py
parentdcdd05b0b4c23da0eb39d3b29d40f8865b6b73ee (diff)
downloadcpython-cdf601281f5909b4b7c6e1f10f3a80d3c216cdc3.zip
cpython-cdf601281f5909b4b7c6e1f10f3a80d3c216cdc3.tar.gz
cpython-cdf601281f5909b4b7c6e1f10f3a80d3c216cdc3.tar.bz2
Issue #19413: Restore pre-3.3 reload() semantics of re-finding modules.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index ec10532..a06a02f 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1510,15 +1510,19 @@ def _find_module(name, path):
"""Find a module's loader."""
if not sys.meta_path:
_warnings.warn('sys.meta_path is empty', ImportWarning)
+ is_reload = name in sys.modules
for finder in sys.meta_path:
with _ImportLockContext():
loader = finder.find_module(name, path)
if loader is not None:
# The parent import may have already imported this module.
- if name not in sys.modules:
+ if is_reload or name not in sys.modules:
return loader
else:
- return sys.modules[name].__loader__
+ try:
+ return sys.modules[name].__loader__
+ except AttributeError:
+ return loader
else:
return None