Merge pull request #4653 from adam-azarchs/patch-1

Fix error reporting for parameterless ImportErrors
This commit is contained in:
Takeshi KOMIYA 2018-02-23 00:11:57 +09:00 committed by GitHub
commit b192bbfb15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -179,7 +179,7 @@ def import_object(modname, objpath, objtype='', attrgetter=safe_getattr, warning
if isinstance(real_exc, SystemExit):
errmsg += ('; the module executes module level statement '
'and it might call sys.exit().')
elif isinstance(real_exc, ImportError):
elif isinstance(real_exc, ImportError) and real_exc.args:
errmsg += '; the following exception was raised:\n%s' % real_exc.args[0]
else:
errmsg += '; the following exception was raised:\n%s' % traceback_msg