gh-123446: Fix empty function names in TypeErrors in typeobject#123470
gh-123446: Fix empty function names in TypeErrors in typeobject#123470sobolevn merged 4 commits intopython:mainfrom
TypeErrors in typeobject#123470Conversation
|
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 🤔 |
| 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.
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.
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