Skip to content

gh-135552: Don't clear weakref if wr_object is a type. #136151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nascheme
Copy link
Member

@nascheme nascheme commented Jun 30, 2025

This is an attempt at making a fix that could be backported to old Python versions. In main, I think the best fix is to stop clearing all weakrefs in the GC. However, that seems disruptive enough that we should avoid doing so in a bugfix release. This version of the fix doesn't clear if wr_object is a type and wr_callback == NULL. There is still a small chance this would break some code that expects that weakrefs are cleared by the GC. In the unit test suite, we had test_finalization, test_io and test_gc that was broken by not clearing weakrefs.

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.

1 participant