Skip to content

Tracebacks going through eliot.twisted.inline_callbacks lose some important frames at the end #449

Open
@exarkun

Description

@exarkun

Consider:

from eliot.twisted import inline_callbacks
from twisted.internet.defer import fail

@inline_callbacks
def foo():
    yield
    yield bar()

@inline_callbacks
def bar():
    yield
    raise Exception("Some problem")

foo()

This results in the following output:

$ python2 eliot-tb-example.py 
Unhandled error in Deferred:

Traceback (most recent call last):
  File "eliot-tb-example.py", line 15, in <module>
    foo()
  File ".../twisted/internet/defer.py", line 1613, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File ".../twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
    _inlineCallbacks(None, g, status)
--- <exception caught here> ---
  File ".../twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File ".../twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File ".../eliot/_generators.py", line 141, in wrapper
    value_out = gen.throw(*value_in)
  File "eliot-tb-example.py", line 8, in foo
    yield bar()
  File ".../eliot/_generators.py", line 160, in wrapper
    value_in = yield value_out
exceptions.Exception: Some problem

The 2nd to last frame looks correct to me - line 8 in foo - but the subsequent frame - line 160 in wrapp is wrong. It should be line line 13 in bar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions