[TIP] Annotated tracebacks

Robert Collins robertc at robertcollins.net
Sat Oct 18 02:52:47 PDT 2014


testtools just had this bug opened on it:

https://github.com/testing-cabal/testtools/issues/111

Which has a few contributing issues but one in particular is that
simple tracebacks don't give you the value of variables in parameters,
nor of local variables in the trace.

I'm aware of the implementation details that can make showing those
values fraught (since __str__ and __repr__ can execute arbitrary
code), but I thought I'd do a straw poll here and see who supports the
idea of the traceback module itself offering to format such things
(e.g. via a locals=False parameter to format_list and friends), which
testtools could then backport to older pythons, and use itself to do
this.

In terms of addressing the implementation details, my thoughts today
are to render the traceback once in simple mode, and then once with
variables, and if something throws during the variable render, just
use the simple one.

-Rob

-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Converged Cloud



More information about the testing-in-python mailing list