-
-
Notifications
You must be signed in to change notification settings - Fork 34k
gh-144169: Fix three crashes in AST objects with non-str kwargs #144178
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
Conversation
|
I closed my PR #144177 since this one is more complete. |
vstinner
left a comment
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.
LGTM. I just left minor suggestions.
| "%.400s got multiple values for argument %R", | ||
| Py_TYPE(self)->tp_name, key); |
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.
Since we are modifying the error message, you must use the safer %T format:
| "%.400s got multiple values for argument %R", | |
| Py_TYPE(self)->tp_name, key); | |
| "%T got multiple values for argument %R", | |
| self, key); |
Same remark for the two other changes below.
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.
It looks like this changes the error message to include the module name:
$ python3.14 -Wall -c 'import ast; ast.Name(idx=3)'
<string>:1: DeprecationWarning: Name.__init__ got an unexpected keyword argument 'idx'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
<string>:1: DeprecationWarning: Name.__init__ missing 1 required positional argument: 'id'. This will become an error in Python 3.15.
$ ./python.exe -Wall -c 'import ast; ast.Name(idx=3)'
<string>:1: DeprecationWarning: ast.Name.__init__ got an unexpected keyword argument 'idx'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
<string>:1: DeprecationWarning: ast.Name.__init__ missing 1 required positional argument: 'id'. This will become an error in Python 3.15.
I feel like that's a change we should only make in 3.15, not in the bugfix releases.
Why is %T safer?
Co-authored-by: Victor Stinner <vstinner@python.org>
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…pythonGH-144178) (cherry picked from commit 639c1ad) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
|
Sorry, @JelleZijlstra, I could not cleanly backport this to |
|
GH-144227 is a backport of this pull request to the 3.14 branch. |
Uh oh!
There was an error while loading. Please reload this page.