break
level += 1
return _bootstrap._gcd_import(name[level:], package, level)
- raise ImportError(msg.format(parentname), name=parent_name)
+
+
+_RELOADING = {}
+
+
+def reload(module):
+ """Reload the module and return it.
+
+ The module must have been successfully imported before.
+
+ """
+ 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:
+ msg = "module {} not in sys.modules"
+ raise ImportError(msg.format(name), name=name)
+ if name in _RELOADING:
+ return _RELOADING[name]
+ _RELOADING[name] = module
+ try:
+ parent_name = name.rpartition('.')[0]
+ 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)
+ finally:
+ try:
+ del _RELOADING[name]
+ except KeyError:
+ pass
Library
-------
-- Issue #18681: Fix a NameError in imp.reload() (noticed by Weizhao Li).
++- Issue #18681: Fix a NameError in importlib.reload() (noticed by Weizhao Li).
+
-- Issue #8112: xlmrpc.server's DocXMLRPCServer server no longer raises an error
- if methods have annotations; it now correctly displays the annotations.
+- Issue #14323: Expanded the number of digits in the coefficients for the
+ RGB -- YIQ conversions so that they match the FCC NTSC versions.
- Issue #17998: Fix an internal error in regular expression engine.