Traceback object removed from Failure when it reaches end of Deferred callback chain
|Reported by:||forrestv||Owned by:||forrestv|
(Moved from mention in #3622)
When a Deferred is errback'd with no handlers currently in the callback chain, the Failure is cleaned (with cleanFailure) and then stored in the Deferred's DebugInfo. However, the Deferred's Failure is not copied, but instead used for this, mutating it.
If the Deferred is used in an @inlineCallbacks function and caught as a normal exception, it then has a useless traceback:
import traceback from twisted.internet import defer def a(): 1/0 @defer.inlineCallbacks def b(): try: result = yield defer.maybeDeferred(a) except Exception: traceback.print_exc() else: print result b()
Traceback (most recent call last): File "test_failure_traceback.py", line 11, in b result = yield defer.maybeDeferred(a) ZeroDivisionError: integer division or modulo by zero