-
-
Notifications
You must be signed in to change notification settings - Fork 273
Closed
Description
When using the exception log method outside an exception handler, the ExceptionDictTransformer raises an AttributeError as it calls extract, which does not handle the case where the given exception type is None.
While according to the Python docs1 this method should only be used from exception handlers, I ran into this issue as the aio-pika (aiormq) library uses it outside an exception handler (issue). (I have configured structlog as the formatter for all loggers, using this setup)
Note that the default _format_exception formatter handles this case properly, as it handles (None, None, None) exc_info2.
Reproduction:
import structlog
print(structlog.__version__) # 24.4.0
structlog.configure([structlog.processors.dict_tracebacks])
structlog.get_logger().exception("oh no") # AttributeError: 'NoneType' object has no attribute '__name__'. Did you mean: '__ne__'?
Footnotes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels