diff options
author | Garvit Khatri <garvit.khatri@zomato.com> | 2017-05-24 22:19:50 (GMT) |
---|---|---|
committer | Brett Cannon <brettcannon@users.noreply.github.com> | 2017-05-24 22:19:50 (GMT) |
commit | 94987826e89e8a89c20f081e18be33fc840e6203 (patch) | |
tree | 2520853181960af114e49c6635ee071b03e2af3c /Lib/importlib/__init__.py | |
parent | 3480ef9dd3177be8c0d71a74853dca6e5b11fbe1 (diff) | |
download | cpython-94987826e89e8a89c20f081e18be33fc840e6203.zip cpython-94987826e89e8a89c20f081e18be33fc840e6203.tar.gz cpython-94987826e89e8a89c20f081e18be33fc840e6203.tar.bz2 |
bpo-29851: Have importlib.reload() raise ImportError if the module's spec is not found (GH-972)
Diffstat (limited to 'Lib/importlib/__init__.py')
-rw-r--r-- | Lib/importlib/__init__.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py index 86febff..cb37d24 100644 --- a/Lib/importlib/__init__.py +++ b/Lib/importlib/__init__.py @@ -164,6 +164,8 @@ def reload(module): pkgpath = None target = module spec = module.__spec__ = _bootstrap._find_spec(name, pkgpath, target) + if spec is None: + raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name) _bootstrap._exec(spec, module) # The module may have replaced itself in sys.modules! return sys.modules[name] |