On 07:54 am, gl...@divmod.com wrote:
2. When filing that ticket, I'd really like a full working example of inlineCallbacks not showing a traceback to play with

Just to drive that point home, Terry, I found an interesting error in your initial example. Your example does this:

       info = sys.exc_info()
       f = failure.Failure(*info)

but sys.exc_info() is a tuple of (type, value, traceback), whereas Failure takes a tuple of (value, type, traceback). This is why the default behavior of Failure() with no arguments is to capture the current exception.

Creating an invalid Failure, as you do here, has some _very_ weird ramifications for the low-level error-formatting code in the guts of the logging system; the reason the traceback doesn't get logged is due to an exception where your ZeroDivisionError instance doesn't have a __module__ attribute (since it's in the "type" slot).

If I modify your example to pass the arguments in the correct order, like so:

   import sys
   from twisted.internet import defer
   from twisted.python import failure

   d = defer.Deferred()
   try:
       1 / 0
   except Exception:
       exc_type, exc_value, exc_tb = sys.exc_info()
       f = failure.Failure(exc_value, exc_type, exc_tb)
       print "f.tb is %r" % f.tb
       d.errback(f)
       print "f.tb is %r" % f.tb

then I get a nice traceback, like this:

   f.tb is <traceback object at 0xb7c628c4>
   f.tb is None
   Unhandled error in Deferred:
   Traceback (most recent call last):
     File "example.py", line 10, in <module>
       f = failure.Failure(exc_value, exc_type, exc_tb)
   --- <exception caught here> ---
     File "example.py", line 7, in <module>
       1 / 0
   exceptions.ZeroDivisionError: integer division or modulo by zero

which is exactly what Failure is designed to do, i.e. produce useful tracebacks once the actual "traceback" instance is gone.

So, we still have some diagnosis to do on why you don't seem to be getting useful tracebacks from inlineCallbacks :). Now, not only can I not reproduce the bug, your reasoning doesn't make sense any more either.

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to