Skip to content

Conversation

@colesbury
Copy link
Contributor

@colesburycolesbury commented Jan 17, 2026

The assignment to generator_return_kind must be after any potentially escaping calls to ensure that it's not overwritten.

…n_kind The assignment to generator_return_kind has to be after any potentially escaping calls or it might be overwritten.
Comment on lines 2271 to 2279
class CallGeneratorOnDealloc:
def __del__(self):
def gen():
yield 1
next(gen())

async def coro():
obj = CallGeneratorOnDealloc()
return 42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bit smaller in size:

Suggested change
classCallGeneratorOnDealloc:
def__del__(self):
defgen():
yield1
next(gen())
asyncdefcoro():
obj=CallGeneratorOnDealloc()
return42
classCallGeneratorOnDealloc:
def__del__(self):
next(xforxin [42])
asyncdefcoro():
obj=CallGeneratorOnDealloc()

Copy link
Contributor

@kumaraditya303kumaraditya303 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@colesburycolesbury enabled auto-merge (squash) January 20, 2026 17:25
@colesburycolesbury disabled auto-merge January 20, 2026 17:26
@colesburycolesbury enabled auto-merge (squash) January 20, 2026 17:26
@colesburycolesbury merged commit 43bb630 into python:mainJan 20, 2026
53 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@colesbury@kumaraditya303@johnslavik