Skip to content

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

Closed
nascheme wants to merge 1 commit into
python:mainfrom
nascheme:gh-135552-no-clear-weakref
Closed

nascheme wants to merge 1 commit into
python:mainfrom
nascheme:gh-135552-no-clear-weakref

Conversation

@nascheme

@nascheme nascheme commented Jun 30, 2025 •

Copy link
Copy Markdown
Member

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.

@nascheme

nascheme commented Jul 1, 2025

Copy link
Copy Markdown
Member Author

I don't think this is safe actually, could introduce bugs like bpo-38006.

@nascheme nascheme closed this Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant