gh-144169: Fix three crashes in AST objects with non-str kwargs#144178
gh-144169: Fix three crashes in AST objects with non-str kwargs#144178JelleZijlstra merged 2 commits intopython:mainfrom
Conversation
|
I closed my PR #144177 since this one is more complete. |
vstinner
left a comment
There was a problem hiding this comment.
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.
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.
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 <[email protected]>
|
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 <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
|
Sorry, @JelleZijlstra, I could not cleanly backport this to |
|
GH-144227 is a backport of this pull request to the 3.14 branch. |
GH-144178) (#144227) gh-144169: Fix three crashes in AST objects with non-str kwargs (GH-144178) (cherry picked from commit 639c1ad) Co-authored-by: Jelle Zijlstra <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
|
@JelleZijlstra: Do you want to try backporting the change manually to 3.13? |
|
GH-144260 is a backport of this pull request to the 3.13 branch. |
GH-144178) (#144260) (cherry picked from commit 639c1ad) Co-authored-by: Jelle Zijlstra <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
…python#144178) Co-authored-by: Victor Stinner <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.