Issue #19720: Suppressed context for some exceptions in importlib.

This commit is contained in:
Serhiy Storchaka 2014-11-21 20:33:57 +02:00
parent b6e2556d8f
commit c4464052d9
3 changed files with 6 additions and 5 deletions

View file

@ -73,7 +73,7 @@ def find_loader(name, path=None):
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 @@ 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)
raise ImportError(msg.format(parent_name),
name=parent_name) from None
else:
pkgpath = parent.__path__
else: