diff options
author | Charles-François Natali <neologix@free.fr> | 2011-10-04 23:37:43 +0200 |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-10-04 23:37:43 +0200 |
commit | 4637309ee66381d081e3e86f72665ca08fc6e634 (patch) | |
tree | ac7a1b38836ac1baa5d63de1e4c565a5e4f583d2 /Python/getargs.c | |
parent | 09252c4938aa14eafc1937e3b17af2f51f8cf123 (diff) | |
parent | e1335c711c555567a9951dd5c1dfde85545445d4 (diff) | |
download | cpython-git-4637309ee66381d081e3e86f72665ca08fc6e634.tar.gz |
Merge.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 21 |
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; } |