summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-04 18:53:03 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-04 18:53:03 (GMT)
commite1335c711c555567a9951dd5c1dfde85545445d4 (patch)
treece073dc242b4399ed8bcc67062d7896fb717908d /Python/getargs.c
parente06e145943854d398adfe053cec757e269af0631 (diff)
downloadcpython-e1335c711c555567a9951dd5c1dfde85545445d4.zip
cpython-e1335c711c555567a9951dd5c1dfde85545445d4.tar.gz
cpython-e1335c711c555567a9951dd5c1dfde85545445d4.tar.bz2
Fix usage og PyUnicode_READY()
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 0e7d9c4..2c2db36 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -834,14 +834,21 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'C': {/* unicode char */
int *p = va_arg(*p_va, int *);
- if (PyUnicode_Check(arg) &&
- PyUnicode_GET_LENGTH(arg) == 1) {
- int kind = PyUnicode_KIND(arg);
- void *data = PyUnicode_DATA(arg);
- *p = PyUnicode_READ(kind, data, 0);
- }
- else
+ int kind;
+ void *data;
+
+ if (!PyUnicode_Check(arg))
+ return converterr("a unicode character", arg, msgbuf, bufsize);
+
+ if (PyUnicode_READY(arg))
+ RETURN_ERR_OCCURRED;
+
+ if (PyUnicode_GET_LENGTH(arg) != 1)
return converterr("a unicode character", arg, msgbuf, bufsize);
+
+ kind = PyUnicode_KIND(arg);
+ data = PyUnicode_DATA(arg);
+ *p = PyUnicode_READ(kind, data, 0);
break;
}