summaryrefslogtreecommitdiff
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-04 20:53:03 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-04 20:53:03 +0200
commit00c5b764e1936139724dd9970fb509f3c2ab1eb2 (patch)
treedd5847b58cb8329f544c65a4b33e347543853064 /Python/getargs.c
parent6d05d09f2654d0e43bd88148c015425eb64aa5bf (diff)
downloadcpython-00c5b764e1936139724dd9970fb509f3c2ab1eb2.tar.gz
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 0e7d9c4350..2c2db36193 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;
}