-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-123446: Fix empty function names in TypeErrors in typeobject
#123470
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
|
After the last change: >>> int().__pow__()
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
int().__pow__()
~~~~~~~~~~~~~^^
TypeError: expected 1 or 2 arguments, got 0
>>> int().__mul__()
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
int().__mul__()
~~~~~~~~~~~~~^^
TypeError: expected 1 argument, got 0
>>> int().__rmul__()
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
int().__rmul__()
~~~~~~~~~~~~~~^^
TypeError: expected 1 argument, got 0Do I need to test this? Seems rather small, but in a very critical part 🤔 |
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.
| if (size == -1) { | ||
| return NULL; | ||
| } | ||
| other = PyTuple_GET_ITEM(args, 0); | ||
| if (size == 2) { | ||
| third = PyTuple_GET_ITEM(args, 1); | ||
| } |
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.
This could also be moved into check_pow_args (or rather unpack_pow_args).
BTW, it is still a question whether __rpow__ and __ipow__ should support the third argument. Normally they never called with three arguments. So it may be better to leave the current PR code, it will be easier to change in future.
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.
Yes, we can open a new issue about that. For now, we only change the error message, not any logical parts. Thanks a lot for the review! 👍
The second option was to convert these functions to use
check_num_args(args, ...), but this feels like a simplier solution.After:
PyArg_UnpackTupleis used withname=""#123446