summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2002-01-09 16:21:27 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2002-01-09 16:21:27 (GMT)
commit3e3eacb5fc886008fe15fdf331bb606070411d1c (patch)
tree52b3c21d1d3a56aec15b984c12fb37a3e7f4cf01 /Python
parente0b1e6af5800368c83e780ce5e29d906fe7b9ae6 (diff)
downloadcpython-3e3eacb5fc886008fe15fdf331bb606070411d1c.zip
cpython-3e3eacb5fc886008fe15fdf331bb606070411d1c.tar.gz
cpython-3e3eacb5fc886008fe15fdf331bb606070411d1c.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/getargs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 9df2a2e..411c695 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -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