Close #14085: remove assertions from PyUnicode_WRITE macro

Add checks in PyUnicode_WriteChar() and convert PyUnicode_New() assertion to a
test raising a Python exception.
This commit is contained in:
Victor Stinner 2012-03-04 01:34:37 +01:00
parent d263d18553
commit c9590ad745
2 changed files with 10 additions and 4 deletions

View file

@ -499,17 +499,14 @@ enum PyUnicode_Kind {
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); \
} \