[Twisted-Python] Re: Making a duck-typed traceback from a Failure

Jonathan Lange jml at mumak.net
Wed Feb 28 19:16:17 EST 2007

On 2/28/07, Jonathan Lange <jml at mumak.net> wrote:
> Is it possible to make a duck-typed traceback from a cleaned Failure?
> I haven't really looked into it, but I can't think of why not off the
> top of my head. Granted I ran out of thought gluons a couple of hours
> ago.

<exarkun> jml: if you refine the question with some details (why isn't
there a real traceback, what do you want to do with the reconstructed
traceback, etc), I might be able to produce some useful feedback

1. Why isn't there a real traceback

The failure is caught in an errback in Trial's run().
Deferred._runCallbacks calls Failure.cleanFailure on any failures that
are returned from Deferreds. By the time the TestResult object gets
the failure, cleanFailure() has been run on it.

cleanFailure() sets Failure.tb to None, and converts all of the frames
into strings. This ensures that we don't keep references to a billion
different objects every time there is a failure.

2. What do I want to do with it

I want to pass the duck-typed traceback along with the exception type
and exception value to traceback.format_exception.


More information about the Twisted-Python mailing list