gh-117557: Improve error message for 'C' format if given string is not 1 char long#117558
gh-117557: Improve error message for 'C' format if given string is not 1 char long#117558erlend-aasland wants to merge 10 commits intopython:mainfrom
Conversation
…ng for int(accept={str}) Argument Clinic converter
This comment was marked as outdated.
This comment was marked as outdated.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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.