Author Trundle
Recipients Trundle
Date 2016-11-03.21:22:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1478208134.4.0.220857012408.issue28603@psf.upfronthosting.co.za>
In-reply-to
Content
The traceback module tries to handle loops caused by an exception's __cause__ or __context__ attributes when printing tracebacks. To do so, it adds already seen exceptions to a set. Unfortunately, it doesn't handle unhashable exceptions:

>>> class E(Exception): __hash__ = None
...
>>> traceback.print_exception(E, E(), None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/traceback.py", line 100, in print_exception
    type(value), value, tb, limit=limit).format(chain=chain):
  File "/usr/lib/python3.5/traceback.py", line 439, in __init__
    _seen.add(exc_value)
TypeError: unhashable type: 'E'

CPython's internal exception printing pretty much does the same, except it ignores any exception while operating on the seen set (see https://hg.python.org/cpython/file/8ee4ed577c03/Python/pythonrun.c#l813 ff).

Attached is a patch that makes the traceback module ignore TypeErrors while operating on the seen set. It also adds a (minimal) test.
History
Date User Action Args
2016-11-03 21:22:14Trundlesetrecipients: + Trundle
2016-11-03 21:22:14Trundlesetmessageid: <1478208134.4.0.220857012408.issue28603@psf.upfronthosting.co.za>
2016-11-03 21:22:14Trundlelinkissue28603 messages
2016-11-03 21:22:14Trundlecreate