diff Python/getargs.c @ 72679:b66033a0f140

Fix usage og PyUnicode_READY()
author Victor Stinner <victor.stinner@haypocalc.com>
date Tue, 04 Oct 2011 20:53:03 +0200
parents 8beaa9a37387
children 6358e5d29dea
line wrap: on
line diff
--- a/Python/getargs.c	Tue Oct 04 20:52:31 2011 +0200
+++ b/Python/getargs.c	Tue Oct 04 20:53:03 2011 +0200
@@ -834,14 +834,21 @@
 
     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;
     }