-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
PyArg_ParseTupleAndKeywords() and non-ASCII keyword names #110815
Comments
…ndKeywords() It already mostly worked, except in the case when invalid keyword argument with non-ASCII name was passed to function with non-ASCII parameter names. Then it crashed in the debug mode.
I am not sure how to classify this issue: as a bug or a new feature. On one hand, it was a regression in 3.7, crash is worse than wrong error message. On other hand, it was not explicitly documented that non-ASCII names are supported, there were no tests, and if it worked, it was only by accident. And it was a long time ago. So, official support of non-ASCII names can be a new feature. |
…ndKeywords() It already mostly worked, except in the case when invalid keyword argument with non-ASCII name was passed to function with non-ASCII parameter names. Then it crashed in the debug mode.
…honGH-110817) (cherry picked from commit 548ce09) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Is the issue visible from Python code:
works. If something like this were to crash, I would say definitely a bugfix to be backported. |
It is an issue with |
…ords() (GH-110816) It already mostly worked, except in the case when invalid keyword argument with non-ASCII name was passed to function with non-ASCII parameter names. Then it crashed in the debug mode.
Thanks. Makes sense now. |
…ndKeywords() (pythonGH-110816) It already mostly worked, except in the case when invalid keyword argument with non-ASCII name was passed to function with non-ASCII parameter names. Then it crashed in the debug mode.
…ndKeywords() (pythonGH-110816) It already mostly worked, except in the case when invalid keyword argument with non-ASCII name was passed to function with non-ASCII parameter names. Then it crashed in the debug mode.
Most of C strings in the C API are implied to be UTF-8 encoded. PyArg_ParseTupleAndKeywords() mostly works with non-ASCII keyword names as they are UTF-8 encoded. Except one case, when you pass argument by keyword with invalid non-ASCII name to a function that has optional parameter with non-ASCII UTF-8 encoded name. In this case you get a crash in the debug build.
It was caused by combination of f4934ea and a83a6a3 (bpo-28701, #72887). Before these changes you simply got inaccurate or even wrong error message.
Examples:
Parameters: "ä"
Keyword arguments: "ë"
Old behavior: TypeError "'ë' is an invalid keyword argument for this function"
Current behavior: crash
Expected behavior: TypeError "'ë' is an invalid keyword argument for this function"
Parameters: "ä"
Keyword arguments: "ä"
Old behavior: TypeError "invalid keyword argument for this function"
Current behavior: crash
Expected behavior: TypeError "'ä' is an invalid keyword argument for this function"
Parameters: "ä", "ë"
Keyword arguments: "ä", "ë"
Old behavior: TypeError "'ë' is an invalid keyword argument for this function"
Current behavior: crash
Expected behavior: TypeError "'ä' is an invalid keyword argument for this function"
In case 1 the pre-bpo-28701 behavior was correct, in case 2 it was correct but not precise (it failed to find the name of invalid keyword argument), in case 3 it was wrong (it found wrong name). In all cases there is a crash currently.
Linked PRs
The text was updated successfully, but these errors were encountered: