Repository navigation
Align weak-reference collection with Python 3.15 finalization #9168
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
Merged
youknowone
merged 5 commits into
RustPython:main
from
youknowdot:fix/weakref-gc-lifecycle
Oct 17, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1df14b3
Align weak-reference collection with Python 3.15 finalization
youknowdot 429c771
Refresh canonical IO tests for weakref finalization
youknowdot f8a8d64
Protect weakref callbacks with the original referent stripe
youknowdot 51e0ffe
Defer weakref GC tracking until referent publication
youknowdot 5cbebf4
Retain the original weakref stripe lock like CPython
youknowdot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverses the existing assertion so that
wr()must now be non-Noneand adds companion callback assertions, while the same patch also rewrites the GC, weakref, and IO canonical suites. Repository policy permits test-file edits only for adding or removing expected-failure markers, so these behavioral test changes cannot land in this form; keep the production/native Rust fix but revert the directLib/testlogic and assertion changes.AGENTS.md reference: AGENTS.md:L278-L282
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion and its callback controls are the canonical CPython 3.15 expectations, imported through update_lib in 1df14b3 as part of the explicitly requested Python 3.15 migration. They were not hand-edited to accommodate this implementation.
I checked the complete test_finalization.py at this head against pinned CPython d220409a13b77de7a6c30abe16ea90db01528edc: both have the identical Git blob 9dd68cf8d574139d990659827cd7f210f953bcc9. The exact upstream resurrection assertions are here: https://github.com/python/cpython/blob/d220409a13b77de7a6c30abe16ea90db01528edc/Lib/test/test_finalization.py#L273-L296 . The related weakref/GC and complete IO-package updates likewise belong to the documented update_lib migration, rather than selected assertion rewrites.
The latest 5cbebf4 commit changes only Rust core.rs to retain the original stripe lock. Reverting this canonical expectation would restore the older Python behavior the requested migration is intended to replace; I am keeping the imported coverage intact.