Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Unified Diff: Lib/importlib/__init__.py

Issue 19413: Reload semantics changed unexpectedly in Python 3.3
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/importlib/_bootstrap.py ('k') | Lib/test/test_importlib/test_api.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -104,10 +104,11 @@
The module must have been successfully imported before.
"""
+ # XXX Is this check wrong?
if not module or not isinstance(module, types.ModuleType):
raise TypeError("reload() argument must be module")
name = module.__name__
- if name not in sys.modules:
+ if sys.modules.get(name) is not module:
msg = "module {} not in sys.modules"
raise ImportError(msg.format(name), name=name)
if name in _RELOADING:
@@ -118,6 +119,7 @@
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)
+ module.__loader__ = _bootstrap._find_module(name, None)
module.__loader__.load_module(name)
# The module may have replaced itself in sys.modules!
return sys.modules[module.__name__]
« no previous file with comments | « Lib/importlib/_bootstrap.py ('k') | Lib/test/test_importlib/test_api.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+