Backport of the Python stdlib traceback module
Python Makefile
Switch branches/tags
Clone or download
zaneb and berkerpeksag bpo-28603: Fix tracebacks for unhashable exceptions (GH-11)
TracebackException checks for loops between exceptions to prevent an
infinite traceback. It does this by putting the already-seen exception
into a set. This means that unhashable exception objects will cause an
error - an error that itself can likely not be printed because of the
presence of the unhashable exception in the chain.

In this case, we don't actually care about equality of the objects as
defined by the class designer; we want to check that we don't encounter
the self-same exception object, from a chain that is necessarily all in
memory at the same time. We can trivially do so by comparing identities
instead of equality.
Latest commit 2e212de Mar 23, 2018

README.rst

A backport of traceback to older supported Pythons.

>>> import traceback2 as traceback

Profit.

Things to be aware of!

In Python 2.x, unlike traceback, traceback2 creates unicode output (because it depends on the linecache2 module).

Exception frame clearing silently does nothing if the interpreter in use does not support it.

traceback2._some_str, which while not an official API is so old its likely in use behaves similarly to the Python3 version - objects where unicode(obj) fails but str(object) works will be shown as b'thestrvaluerepr'.