[Python-checkins] CVS: python/dist/src/Python getargs.c,2.90,2.91
M.-A. Lemburg
lemburg@users.sourceforge.net
Wed, 09 Jan 2002 08:21:30 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv11966/Python
Modified Files:
getargs.c
Log Message:
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.
Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.90
retrieving revision 2.91
diff -C2 -d -r2.90 -r2.91
*** getargs.c 2001/12/03 00:43:33 2.90
--- getargs.c 2002/01/09 16:21:27 2.91
***************
*** 839,852 ****
void **p = (void **)va_arg(*p_va, char **);
int *q = va_arg(*p_va, int *);
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);
--- 839,856 ----
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);