(original) (raw)
changeset: 93529:2de3c659a979 user: Serhiy Storchaka storchaka@gmail.com date: Fri Nov 21 20:33:57 2014 +0200 files: Lib/importlib/__init__.py Lib/importlib/_bootstrap.py Lib/importlib/util.py description: Issue #19720: Suppressed context for some exceptions in importlib. diff -r 8558fff73032 -r 2de3c659a979 Lib/importlib/__init__.py --- a/Lib/importlib/__init__.py Fri Nov 21 12:19:28 2014 -0500 +++ b/Lib/importlib/__init__.py Fri Nov 21 20:33:57 2014 +0200 @@ -73,7 +73,7 @@ except KeyError: pass except AttributeError: - raise ValueError('{}.__loader__ is not set'.format(name)) + raise ValueError('{}.__loader__ is not set'.format(name)) from None spec = _bootstrap._find_spec(name, path) # We won't worry about malformed specs (missing attributes). @@ -138,7 +138,8 @@ parent = sys.modules[parent_name] except KeyError: msg = "parent {!r} not in sys.modules" - raise ImportError(msg.format(parent_name), name=parent_name) + raise ImportError(msg.format(parent_name), + name=parent_name) from None else: pkgpath = parent.__path__ else: diff -r 8558fff73032 -r 2de3c659a979 Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Fri Nov 21 12:19:28 2014 -0500 +++ b/Lib/importlib/_bootstrap.py Fri Nov 21 20:33:57 2014 +0200 @@ -2172,7 +2172,7 @@ path = parent_module.__path__ except AttributeError: msg = (_ERR_MSG + '; {!r} is not a package').format(name, parent) - raise ImportError(msg, name=name) + raise ImportError(msg, name=name) from None spec = _find_spec(name, path) if spec is None: raise ImportError(_ERR_MSG.format(name), name=name) diff -r 8558fff73032 -r 2de3c659a979 Lib/importlib/util.py --- a/Lib/importlib/util.py Fri Nov 21 12:19:28 2014 -0500 +++ b/Lib/importlib/util.py Fri Nov 21 20:33:57 2014 +0200 @@ -56,7 +56,7 @@ try: spec = module.__spec__ except AttributeError: - raise ValueError('{}.__spec__ is not set'.format(name)) + raise ValueError('{}.__spec__ is not set'.format(name)) from None else: if spec is None: raise ValueError('{}.__spec__ is None'.format(name)) @@ -96,7 +96,7 @@ try: spec = module.__spec__ except AttributeError: - raise ValueError('{}.__spec__ is not set'.format(name)) + raise ValueError('{}.__spec__ is not set'.format(name)) from None else: if spec is None: raise ValueError('{}.__spec__ is None'.format(name)) /storchaka@gmail.com