gh-123446: Fix empty function names in TypeErrors in typeobject#123470
Merged
sobolevn merged 4 commits intopython:mainfrom Aug 30, 2024
Merged
gh-123446: Fix empty function names in TypeErrors in typeobject#123470sobolevn merged 4 commits intopython:mainfrom
TypeErrors in typeobject#123470sobolevn merged 4 commits intopython:mainfrom
Conversation
Member
Author
|
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 🤔 |
blhsing
reviewed
Aug 30, 2024
blhsing
reviewed
Aug 30, 2024
serhiy-storchaka
approved these changes
Aug 30, 2024
Comment on lines
+8805
to
+8811
| if (size == -1) { | ||
| return NULL; | ||
| } | ||
| other = PyTuple_GET_ITEM(args, 0); | ||
| if (size == 2) { | ||
| third = PyTuple_GET_ITEM(args, 1); | ||
| } |
Member
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.
Member
Author
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! 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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