Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Closed
nascheme wants to merge 1 commit into
python:mainpython/cpython:mainfrom
nascheme:gh-135552-no-clear-weakrefnascheme/cpython:gh-135552-no-clear-weakrefCopy head branch name to clipboard
Closed

gh-135552: Don't clear weakref if wr_object is a type.#136151
nascheme wants to merge 1 commit into
python:mainpython/cpython:mainfrom
nascheme:gh-135552-no-clear-weakrefnascheme/cpython:gh-135552-no-clear-weakrefCopy head branch name to clipboard

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.