Closed
Description
Bug report
Bug description:
class MyExc(Exception):
pass
import itertools
async def agenfn():
for i in itertools.count():
try:
yield i
except MyExc:
pass
agen = agenfn()
try:
agen.asend(None).send(None)
except StopIteration as e:
print(f"{e.value=}")
athrow = agen.athrow(MyExc)
try:
athrow.throw(MyExc)
except StopIteration as e:
print(f"{e.value=}")
try:
athrow.throw(MyExc)
except RuntimeError:
print("good")
except StopIteration as e:
print(f"bad {e.value=}")
outputs:
e.value=0
e.value=1
bad e.value=2
should output:
e.value=0
e.value=1
good
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux