Closed
Description
Bug report
Bug description:
async def agen():
return
yield
try:
athrow = agen().athrow()
athrow.close()
except TypeError:
print("good")
else:
print("bad")
output:
bad
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux
Activity
graingert commentedon Apr 13, 2024
to get the error you have to actually await the coroutine:
output:
duaneg commentedon May 28, 2025
Fixing this would be a change in behaviour, but it is hard to imagine it breaking any working code.
pythongh-117852: eagerly check arguments to asyncgen.athrow()
gh-117852: fix argument checking of `async_generator.athrow` (#134868)