PyUnicode_GET_SIZE() checks that PyUnicode_AsUnicode() succeed
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 21 Nov 2011 01:24:49 +0000 (02:24 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 21 Nov 2011 01:24:49 +0000 (02:24 +0100)
using an assertion

Include/unicodeobject.h

index 6a31e48836f8181e9811734696c82d839da94c24..e1a5a2f5f7da7329b3222f3dd5c6c36f8976692e 100644 (file)
@@ -385,12 +385,13 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
    If the Py_UNICODE representation is not available, it will be computed
    on request.  Use PyUnicode_GET_LENGTH() for the length in code points. */
 
-#define PyUnicode_GET_SIZE(op) \
-    (assert(PyUnicode_Check(op)), \
-     (((PyASCIIObject *)(op))->wstr) ? \
-        PyUnicode_WSTR_LENGTH(op) :                   \
-        ((void)PyUnicode_AsUnicode((PyObject *)(op)), \
-         PyUnicode_WSTR_LENGTH(op)))
+#define PyUnicode_GET_SIZE(op)                       \
+    (assert(PyUnicode_Check(op)),                    \
+     (((PyASCIIObject *)(op))->wstr) ?               \
+      PyUnicode_WSTR_LENGTH(op) :                    \
+      ((void)PyUnicode_AsUnicode((PyObject *)(op)),  \
+       assert(((PyASCIIObject *)(op))->wstr),        \
+       PyUnicode_WSTR_LENGTH(op)))
 
 #define PyUnicode_GET_DATA_SIZE(op) \
     (PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE)