diff Include/unicodeobject.h @ 74702:056f5cc8885d

Issue #13706: Add assertions to detect bugs earlier
author Victor Stinner <victor.stinner@haypocalc.com>
date Wed, 01 Feb 2012 00:22:23 +0100
parents 6bb05ce1cd1f
children f89e2f4cda88
line wrap: on
line diff
--- a/Include/unicodeobject.h	Tue Jan 31 17:02:10 2012 -0500
+++ b/Include/unicodeobject.h	Wed Feb 01 00:22:23 2012 +0100
@@ -499,14 +499,17 @@
     do { \
         switch ((kind)) { \
         case PyUnicode_1BYTE_KIND: { \
+            assert(value <= 0xff); \
             ((Py_UCS1 *)(data))[(index)] = (Py_UCS1)(value); \
             break; \
         } \
         case PyUnicode_2BYTE_KIND: { \
+            assert(value <= 0xffff); \
             ((Py_UCS2 *)(data))[(index)] = (Py_UCS2)(value); \
             break; \
         } \
         default: { \
+            assert(value <= 0x10ffff); \
             assert((kind) == PyUnicode_4BYTE_KIND); \
             ((Py_UCS4 *)(data))[(index)] = (Py_UCS4)(value); \
         } \