mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
Fix usage og PyUnicode_READY()
This commit is contained in:
parent
e06e145943
commit
e1335c711c
3 changed files with 27 additions and 12 deletions
|
@ -834,14 +834,21 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
|
||||
case 'C': {/* unicode char */
|
||||
int *p = va_arg(*p_va, int *);
|
||||
if (PyUnicode_Check(arg) &&
|
||||
PyUnicode_GET_LENGTH(arg) == 1) {
|
||||
int kind = PyUnicode_KIND(arg);
|
||||
void *data = PyUnicode_DATA(arg);
|
||||
*p = PyUnicode_READ(kind, data, 0);
|
||||
}
|
||||
else
|
||||
int kind;
|
||||
void *data;
|
||||
|
||||
if (!PyUnicode_Check(arg))
|
||||
return converterr("a unicode character", arg, msgbuf, bufsize);
|
||||
|
||||
if (PyUnicode_READY(arg))
|
||||
RETURN_ERR_OCCURRED;
|
||||
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1)
|
||||
return converterr("a unicode character", arg, msgbuf, bufsize);
|
||||
|
||||
kind = PyUnicode_KIND(arg);
|
||||
data = PyUnicode_DATA(arg);
|
||||
*p = PyUnicode_READ(kind, data, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue