mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Compare and hash unicode objects like their UTF-8 representations.
Accept Unicode characters < 256 for 'c' format.
This commit is contained in:
parent
f15a29f975
commit
09dc34fc9c
2 changed files with 26 additions and 50 deletions
|
@ -764,8 +764,12 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
char *p = va_arg(*p_va, char *);
|
||||
if (PyString_Check(arg) && PyString_Size(arg) == 1)
|
||||
*p = PyString_AS_STRING(arg)[0];
|
||||
else if (PyUnicode_Check(arg) &&
|
||||
PyUnicode_GET_SIZE(arg) == 1 &&
|
||||
PyUnicode_AS_UNICODE(arg)[0] < 256)
|
||||
*p = PyUnicode_AS_UNICODE(arg)[0];
|
||||
else
|
||||
return converterr("char", arg, msgbuf, bufsize);
|
||||
return converterr("char < 256", arg, msgbuf, bufsize);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue