summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/arraymodule.c2
-rw-r--r--Modules/datetimemodule.c2
-rw-r--r--Python/getargs.c13
-rw-r--r--Python/modsupport.c6
4 files changed, 21 insertions, 2 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 6c9038a..2539077 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1785,7 +1785,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (type == &Arraytype && !_PyArg_NoKeywords("array.array()", kwds))
return NULL;
- if (!PyArg_ParseTuple(args, "c|O:array", &c, &initial))
+ if (!PyArg_ParseTuple(args, "C|O:array", &c, &initial))
return NULL;
if (!(initial == NULL || PyList_Check(initial)
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 488d062..61f9ab7 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -4033,7 +4033,7 @@ datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
PyObject *result;
int us = DATE_GET_MICROSECOND(self);
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|c:isoformat", keywords, &sep))
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "|C:isoformat", keywords, &sep))
return NULL;
if (us)
result = PyUnicode_FromFormat("%04d-%02d-%02d%c%02d:%02d:%02d.%06d",
diff --git a/Python/getargs.c b/Python/getargs.c
index 1730bff..ce1fef7 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -761,6 +761,19 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
#endif /* WITHOUT_COMPLEX */
case 'c': {/* char */
+ char *p = va_arg(*p_va, char *);
+ if (PyString_Check(arg) && PyString_Size(arg) == 1)
+ *p = PyString_AS_STRING(arg)[0];
+ else if (PyUnicode_Check(arg) &&
+ PyUnicode_GET_SIZE(arg) == 1 &&
+ PyUnicode_AS_UNICODE(arg)[0] < 256)
+ *p = PyUnicode_AS_UNICODE(arg)[0];
+ else
+ return converterr("char < 256", arg, msgbuf, bufsize);
+ break;
+ }
+
+ case 'C': {/* unicode char */
int *p = va_arg(*p_va, int *);
if (PyString_Check(arg) && PyString_Size(arg) == 1)
*p = PyString_AS_STRING(arg)[0];
diff --git a/Python/modsupport.c b/Python/modsupport.c
index ba46409..330da5f 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -385,6 +385,12 @@ 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);
+ }
+ case 'C':
+ {
int i = va_arg(*p_va, int);
Py_UNICODE c;
if (i < 0 || i > PyUnicode_GetMax()) {