zopefoundation / zope.exceptions

exceptions and implementations which are general purpose
https://zopeexceptions.readthedocs.io/
Other
0 stars 6 forks source link

Support chaining in the exception formatter #11

Open mgedmin opened 6 years ago

mgedmin commented 6 years ago

In zodbbrowser's test suite I monkey-patch traceback.print_exception and traceback.format_exception so I can see the additional bits that zope.exception formatter provides (__traceback_info__ etc.) when an uncaught exception happens in a background thread.

On Python 3 this causes a problem:

Unhandled exception in thread started by <bound method Thread._bootstrap of <Thread(server, started daemon 140073167124224)>>
Traceback (most recent call last):
  ...
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 879, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.4/threading.py", line 921, in _bootstrap_inner
    (self.name, _format_exc()), file=self._stderr)
  File "/usr/lib/python3.4/traceback.py", line 256, in format_exc
    return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
TypeError: format_exception() got an unexpected keyword argument 'chain'

So: I would like to add support for exception chaining.