summaryrefslogtreecommitdiff
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-06-20 11:02:38 +0000
committerWalter Dörwald <walter@livinglogic.de>2007-06-20 11:02:38 +0000
commit8cd880020ddc25d9933f1b0af92ddc8b7a959252 (patch)
tree3bfe4e7989c1223c88d6120335e3f80c2ab8e701 /Python/modsupport.c
parentbee9339ea17ba04f0ae14ab308692de25f4d71fd (diff)
downloadcpython-8cd880020ddc25d9933f1b0af92ddc8b7a959252.tar.gz
Change %c format specifier for PyArg_ParseTuple() so that it accepts
a unicode character (an int * must be passed as the argument). Change %c format specifier for Py_BuildValue() so that it outputs a unicode object. Fix datetime.datetime.isoformat(), so that it works if sep is a unicode character > U+00FF.
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 781a331493..ba464099dd 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -385,9 +385,22 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
case 'c':
{
- char p[1];
- p[0] = (char)va_arg(*p_va, int);
- return PyString_FromStringAndSize(p, 1);
+ int i = va_arg(*p_va, int);
+ Py_UNICODE c;
+ if (i < 0 || i > PyUnicode_GetMax()) {
+#ifdef Py_UNICODE_WIDE
+ PyErr_SetString(PyExc_OverflowError,
+ "%c arg not in range(0x110000) "
+ "(wide Python build)");
+#else
+ PyErr_SetString(PyExc_OverflowError,
+ "%c arg not in range(0x10000) "
+ "(narrow Python build)");
+#endif
+ return NULL;
+ }
+ c = i;
+ return PyUnicode_FromUnicode(&c, 1);
}
case 's':