gh-113753: Clear finalized bit when putting PyAsyncGenASend back into free list (#113754)

This commit is contained in:
Sam Gross 2024-01-10 13:18:38 -05:00 committed by GitHub
parent 901a971e16
commit 73ae2023a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View file

@ -1701,6 +1701,14 @@ class TestUnawaitedWarnings(unittest.TestCase):
async def gen():
yield 1
# gh-113753: asend objects allocated from a free-list should warn.
# Ensure there is a finalized 'asend' object ready to be reused.
try:
g = gen()
g.asend(None).send(None)
except StopIteration:
pass
msg = f"coroutine method 'asend' of '{gen.__qualname__}' was never awaited"
with self.assertWarnsRegex(RuntimeWarning, msg):
g = gen()