Closed graingert closed 1 year ago
@markshannon bisected to 411b1692811b2ecac59cb0df0f920861c7cf179a
It might be related to the fact that YIELD_VALUE
cannot raise...
...but INSTRUMENTED_YIELD_VALUE
can:
That seems incorrect.
This is a little easier for me to follow:
def inner():
try:
yield
except Exception:
print("caught by inner")
yield
def outer():
try:
yield from inner()
except Exception:
print("caught by outer")
yield
gen = outer()
gen.send(None)
gen.throw(Exception)
brandtbucher@faster-cpython:~/cpython$ ./python bug.py
caught by inner
brandtbucher@faster-cpython:~/cpython$ ./python -m trace -c bug.py
caught by outer
Will the actual exception in the trace function be thrown away if we simply remove the error check in instrumented version?
Will the actual exception in the trace function be thrown away if we simply remove the error check in instrumented version?
No, we would need to explicitly clear it.
Is there anything left to do for this issue?
Nope!
Bug report
With the following demo code, a subgenerator
yield from
from a parent generator main(), that catches exceptions and returns "good":when run with
python -m trace
, the exception is delivered to the outer generator main() instead of being suppressedthe problem also occurs with the equivalent generator syntax, eg:
Your environment
see also
https://github.com/urllib3/urllib3/issues/3049#issuecomment-1570452951 https://github.com/nedbat/coveragepy/issues/1635
Linked PRs