[issue13188] generator.throw() ignores __traceback__ of exception

Antoine Pitrou report at bugs.python.org
Sun Oct 16 01:34:30 CEST 2011


New submission from Antoine Pitrou <pitrou at free.fr>:

In the following code, the original traceback attached to the exception thrown into the generator is ignored:

def gen():
    try:
        yield
    except:
        raise

g = gen()
try:
    1/0
except ZeroDivisionError as v:
    g.throw(v)


But if you replace the last line with:

    g.throw(type(v), v, v.__traceback__)

then the original traceback gets appended.
g.throw() should have fetched the __traceback__ attribute by itself.

----------
components: Interpreter Core
messages: 145609
nosy: ncoghlan, pitrou
priority: normal
severity: normal
status: open
title: generator.throw() ignores __traceback__ of exception
type: behavior
versions: Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13188>
_______________________________________


More information about the Python-bugs-list mailing list