Author chris.jerdonek
Recipients chris.jerdonek
Date 2020-05-20.04:47:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589950025.34.0.136144385368.issue40694@roundup.psfhosted.org>
In-reply-to
Content
Here is another gen.throw() exception chain example similar to the examples in issue 29587: https://bugs.python.org/issue29587

def f():
    yield

def g():
    try:
        raise RuntimeError('a')
    except Exception as exc:
        print(f'handling: {exc!r}')
        yield from f()

def h():
    try:
        raise RuntimeError('b')
    except Exception as exc:
        print(f'handling: {exc!r}')
        yield from g()

gen = h()
gen.send(None)
gen.throw(ValueError)

Output:

handling: RuntimeError('b')
handling: RuntimeError('a')
Traceback (most recent call last):
  File "/.../test.py", line 13, in h
    raise RuntimeError('b')
RuntimeError: b

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.../test.py", line 20, in <module>
    gen.throw(ValueError)
  File "/.../test.py", line 16, in h
    yield from g()
  File "/.../test.py", line 9, in g
    yield from f()
  File "/.../test.py", line 2, in f
    yield
ValueError

The issue is that "RuntimeError: a" is skipped. It should also appear in the exception chain.

I believe this has the same root cause as issue 29590: https://bugs.python.org/issue29590
History
Date User Action Args
2020-05-20 04:47:05chris.jerdoneksetrecipients: + chris.jerdonek
2020-05-20 04:47:05chris.jerdoneksetmessageid: <1589950025.34.0.136144385368.issue40694@roundup.psfhosted.org>
2020-05-20 04:47:05chris.jerdoneklinkissue40694 messages
2020-05-20 04:47:05chris.jerdonekcreate