-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
import types
import itertools
@types.coroutine
def _async_yield(v):
return (yield v)
class MyExc(Exception):
pass
async def agenfn():
for i in itertools.count():
try:
await _async_yield(i)
except MyExc:
pass
return
yield
agen = agenfn()
gen = agen.asend(None)
print(f"{gen.send(None)}")
gen2 = agen.asend(None)
try:
print(f"{gen2.throw(MyExc)}")
except RuntimeError:
print("good")
else:
print("bad")
gen3 = agen.athrow(MyExc)
try:
print(f"{gen3.throw(MyExc)}")
except RuntimeError:
print("good")
else:
print("bad")
outputs:
0
1
bad
2
bad
should print:
0
good
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
Linked PRs
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error