Skip to content

Conversation

@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented Jan 23, 2026

@vstinner
Copy link
Member

I closed my PR #144177 since this one is more complete.

Copy link
Member

@vstinner vstinner left a 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.

Comment on lines +945 to 946
"%.400s got multiple values for argument %R",
Py_TYPE(self)->tp_name, key);
Copy link
Member

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:

Suggested change
"%.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.

Copy link
Member Author

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants