cpython: 2de3c659a979 (original) (raw)
Mercurial > cpython
changeset 93529:2de3c659a979
Issue #19720: Suppressed context for some exceptions in importlib. [#19720]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Fri, 21 Nov 2014 20:33:57 +0200 |
parents | 8558fff73032 |
children | 8f77f7bb46c7 |
files | Lib/importlib/__init__.py Lib/importlib/_bootstrap.py Lib/importlib/util.py |
diffstat | 3 files changed, 6 insertions(+), 5 deletions(-)[+] [-] Lib/importlib/__init__.py 5 Lib/importlib/_bootstrap.py 2 Lib/importlib/util.py 4 |
line wrap: on
line diff
--- a/Lib/importlib/init.py +++ b/Lib/importlib/init.py @@ -73,7 +73,7 @@ def find_loader(name, path=None): except KeyError: pass except AttributeError:
raise ValueError('{}.__loader__ is not set'.format(name))[](#l1.7)
raise ValueError('{}.__loader__ is not set'.format(name)) from None[](#l1.8)
spec = _bootstrap._find_spec(name, path) # We won't worry about malformed specs (missing attributes). @@ -138,7 +138,8 @@ def reload(module): parent = sys.modules[parent_name] except KeyError: msg = "parent {!r} not in sys.modules"
raise ImportError(msg.format(parent_name), name=parent_name)[](#l1.16)
raise ImportError(msg.format(parent_name),[](#l1.17)
name=parent_name) from None[](#l1.18) else:[](#l1.19) pkgpath = parent.__path__[](#l1.20) else:[](#l1.21)
--- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -2172,7 +2172,7 @@ def _find_and_load_unlocked(name, import path = parent_module.path except AttributeError: msg = (_ERR_MSG + '; {!r} is not a package').format(name, parent)
raise ImportError(msg, name=name)[](#l2.7)
spec = _find_spec(name, path) if spec is None: raise ImportError(_ERR_MSG.format(name), name=name)raise ImportError(msg, name=name) from None[](#l2.8)
--- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -56,7 +56,7 @@ def _find_spec_from_path(name, path=None try: spec = module.spec except AttributeError:
raise ValueError('{}.__spec__ is not set'.format(name))[](#l3.7)
raise ValueError('{}.__spec__ is not set'.format(name)) from None[](#l3.8) else:[](#l3.9) if spec is None:[](#l3.10) raise ValueError('{}.__spec__ is None'.format(name))[](#l3.11)
@@ -96,7 +96,7 @@ def find_spec(name, package=None): try: spec = module.spec except AttributeError:
raise ValueError('{}.__spec__ is not set'.format(name))[](#l3.16)
raise ValueError('{}.__spec__ is not set'.format(name)) from None[](#l3.17) else:[](#l3.18) if spec is None:[](#l3.19) raise ValueError('{}.__spec__ is None'.format(name))[](#l3.20)