-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-38009: Do not call weakref callbacks that are being collected #15645
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a826630
bpo-38009: Do not call weakref callbacks that are being collected
pablogsal 012df46
Update the warning message and the comment
pablogsal 1324fb5
Refactor _PyObject_GC_IS_COLLECTING
pablogsal 2fb1c13
Adress feedback and add clarifications
pablogsal 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 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
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
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
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.
What is the actual effect of just returning here? The callback isn't being called, but it wouldn't have been called had all the objects in the cycle had done the right thing, right? So what's the actual value of the warning?
Uh oh!
There was an error while loading. Please reload this page.
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.
The reason we return is to not crash and then we warn that the interpreter has avoided a crash due to a bad implementation but we need to issue the warning so this does not pass silently.
Would you prefer to just crash?
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.
No, I'm trying to find out if there are other reasons that people should fix their code, besides the specific crash that you're now turning into a warning. If the only reason to fix the code is to avoid this warning, the warning just becomes noise -- especially because very often the warning isn't seen by the developer responsible for the incorrect C code, but some helpless user.
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.
Oh, I understand. Well, after this fix there is no hard crash, but an incorrect implementation of the garbage collector can have undefined consequences. These range from leaks because tp_traverse is not correctly implemented or some other crashes elsewhere.
What do you think we should do here? Maybe a more comprehensive message?
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.
I'm thinking less of a message, really :) The message is useful for people who have control over the C code that does the wrong thing, but to end users of the module. Maybe the exception should be a DeprecationWarning, so it's not shown by default? Perhaps we should discuss this on python-dev or discourse.