From 86634aeb7cdc39bfd2e81061878d50d25947a7e5 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 21 Nov 2014 20:33:57 +0200 Subject: Issue #19720: Suppressed context for some exceptions in importlib. --- Lib/importlib/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Lib/importlib/__init__.py') diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py index e0fe4665f4..e99f50e0f1 100644 --- 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)) + 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: -- cgit v1.2.1