Commit 010b678
committed
fix(ext.autodoc): fix logging of tracebacks
`traceback.format_exception()` returns a list of strings containing already newlines.
Sphinx just logs the repr of that list, which makes it impossible to read tracebacks easily.
the real and helpful exception trace would be:
```
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/sphinx/ext/autodoc/importer.py", line 175, in import_module
module = importlib.import_module(modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/root/module.py", line 58, in <module>
...
AttributeError: 'NoneType' object has no attribute 'lower'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/sphinx/ext/autodoc/importer.py", line 269, in import_object
module = import_module(modname, try_reload=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/sphinx/ext/autodoc/importer.py", line 187, in import_module
raise ImportError(exc, traceback.format_exc()) from exc
ImportError: (AttributeError("'NoneType' object has no attribute 'lower'"),
```1 parent f224e04 commit 010b678
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| |||
0 commit comments