diff Python/getargs.c @ 21667:0d3bb68e3a28 legacy-trunk

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.
author Marc-André Lemburg <mal@egenix.com>
date Wed, 09 Jan 2002 16:21:27 +0000
parents 87fa6e9bd77e
children f0277146aa16
line wrap: on
line diff
--- a/Python/getargs.c	Tue Jan 08 23:03:45 2002 +0000
+++ b/Python/getargs.c	Wed Jan 09 16:21:27 2002 +0000
@@ -838,16 +838,20 @@
 		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