-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-117557: Improve error message for 'C' format if given string is not 1 char long #117558
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
gh-117557: Improve error message for 'C' format if given string is not 1 char long #117558
Conversation
…ng for int(accept={str}) Argument Clinic converter
This comment was marked as outdated.
This comment was marked as outdated.
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
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.
Is it really better than the current error message?
In any case, you cannot just change the error message in Argument Clinic. It should match the error message in PyArg_Parse.
There are other variants of the error message for the same error in ord
, str.center
, str and bytes formatting %c
. If we change the error messages, it is better to consider all options and make them as consistent as possible.
Yes; it is clearer and more accurate.
They represent different APIs and require different error messages. Aligning them with this error message does not make sense to me. |
Yes, I think there is value in synchronising these. |
- try to make the error message even clearer - sync with PyArg_Parse
I tried to address your concerns in fe02edd, Serhiy. |
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.
Thank you, it is better now. But note that other error message (few lines above) requires "a unicode character", not "a string containing exactly one unicode character". The latter looks as a more clumsy formulation of the former.
Ideally, the error message should contain the length of the string if it is not 1. But the PyArg_Parse
code has limited facilities, so it needs more work.
Please look at more general image. Look how the affected functions are documented. Should the documentation be updated?
Look also at the 'c'
format unit (bytes objects with length 1). Does it need changes?
…rray of length 1 are expected
…rray of length 1 are expected
Closed in favour of #117631. |
Uh oh!
There was an error while loading. Please reload this page.