[Python-Dev] unexpected traceback/stack behavior with chained exceptions (issue 1553375)

R. David Murray rdmurray at bitdance.com
Sun Nov 14 04:40:52 CET 2010


Issue 1553375 [1] proposes a patch to add an 'allframes' option to the
traceback printing and formatting routines so that the full traceback
from the top of the execution stack down to the exception is printed,
instead of just from the point where the exception is caught down to
the exception.  This is useful when the reason you are capturing the
traceback is to log it, and you have several different points in your
application where you do such traceback logging.  You often really want
to know the entire stack in that case; logging only from the capture
point down can lose important debugging information depending on how
the application is structured.

The patch seems to work well, except for one problem that I don't have
enough CPython internals knowledge to understand.  If the traceback we
are printing has a chained traceback, the resulting full traceback shows
the line that is printing the traceback instead of the line from the 'try'
block.  (It prints the expected line if there is no chained traceback).

So, is this a failure in my understanding of how tracebacks are supposed
to work, or a bug in how chained tracebacks are constructed?

[1] http://bugs.python.org/issue1553375

--
R. David Murray                                      www.bitdance.com


More information about the Python-Dev mailing list