Skip to content

Conversation

@p-sawicki
Copy link
Collaborator

When the __cpyfunction__ attribute of callable class objects is initialized in the constructor, it might end up becoming NULL after a freed instance is reused because the attribute gets cleared when deallocating the object and the constructor would only initialize it when creating a new instance.

To fix this, move the initialization outside of the constructor and do it right after. This also makes it consistent with the __mypyc_env__ attribute.

@p-sawicki p-sawicki merged commit b11d314 into python:master Jan 22, 2026
16 checks passed
@p-sawicki p-sawicki deleted the set-cpyfunctin-outside-of-constructor branch January 22, 2026 17:28
Sign up for free to 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.

2 participants