Issue #13706: Add assertions to detect bugs earlier
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index c706fc2..6d580f4 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -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); \
} \