-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
gh-118473: Fix set_asyncgen_hooks not to be partially set when arguments are invalid #118474
Conversation
youknowone
commented
May 1, 2024
•
edited by bedevere-app
bot
edited by bedevere-app
bot
- Issue: sys.set_asyncgen_hooks with invalid firstiter may partially set finalizer #118473
b6b9069
to
c8474fc
Compare
I am starting to review. Please do not force push any more -- you can add new commits, and we will squash them when we merge the code. |
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 sorry, I don't like how you separated the audit calls from the setter functions, since it's conceivable that other (internal) code might call them, and the changes should always be audited.
I think a better refactoring would be to save the current finalizer hook and if setting the firstiter hook fails, restore the original finalizer. It still makes sense of course to do both callable checks before making any of the setter calls.
(Note that in your current PR there is a possible scenario where the second audit hook fails, no setters are called, but the first audit hook has already been called.)
Also, CC @zooba.
@@ -0,0 +1 @@ | |||
Fix set_asyncgen_hooks not to be partially set when raising TypeError |
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.
Please make this proper ReST markup with links to the code for set_asyncgen_hooks
and TypeError
, and end the sentence with a period. (I can help with the markup but consulting other news files should give ample examples.)
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@gvanrossum Thank you for the guide! I have made the requested changes; please review again |
Thanks for making the requested changes! @gvanrossum: please review the changes made to this pull request. |
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.
Thanks! LGTM. I will merge this now, so it will make it into beta 1. Congrats!
@youknowone Do you think this should be backported to Python 3.12? It's a pure bugfix, so I think it could be. |
@gvanrossum No opinion about it. I found this bug not by running code, but by watching CPython source code. It is hard to imagine real world code make a try-except block for |
Then let's not backport. |
…arguments are invalid (python#118474)