mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix error reporting for parameterless ImportErrors
In some cases, a module may raise an ImportError without any arguments, e.g.
if not_allowed():
raise ImportError
In this case, the exception has no args. This is bad practice, but it happens.
Currently, autodoc will crash with
IndexError: tuple index out of range
This commit is contained in:
committed by
Adam Azarchs
parent
56fe1d0414
commit
6a2ec96c97
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user