mirror of
https://github.com/python/cpython.git
synced 2025-07-14 23:05:17 +00:00
Fixed "u#" parser marker to pass through Unicode objects as-is without
going through the buffer interface API. Added tests for this to the _testcapi module and updated docs.
This commit is contained in:
parent
e0b1e6af58
commit
3e3eacb5fc
4 changed files with 61 additions and 2 deletions
|
@ -838,16 +838,20 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
|
|||
if (*format == '#') { /* any buffer-like object */
|
||||
void **p = (void **)va_arg(*p_va, char **);
|
||||
int *q = va_arg(*p_va, int *);
|
||||
if (PyUnicode_Check(arg)) {
|
||||
*p = PyUnicode_AS_UNICODE(arg);
|
||||
*q = PyUnicode_GET_SIZE(arg);
|
||||
}
|
||||
else {
|
||||
char *buf;
|
||||
int count = convertbuffer(arg, p, &buf);
|
||||
|
||||
if (count < 0)
|
||||
return converterr(buf, arg, msgbuf, bufsize);
|
||||
*q = count/(sizeof(Py_UNICODE));
|
||||
}
|
||||
format++;
|
||||
} else {
|
||||
Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
|
||||
|
||||
if (PyUnicode_Check(arg))
|
||||
*p = PyUnicode_AS_UNICODE(arg);
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue