Author Trundle
Recipients Trundle
Date 2016-11-03.21:22:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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/", line 100, in print_exception
    type(value), value, tb, limit=limit).format(chain=chain):
  File "/usr/lib/python3.5/", line 439, in __init__
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 ff).

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