mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
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:
parent
d263d18553
commit
c9590ad745
2 changed files with 10 additions and 4 deletions
|
@ -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); \
|
||||
} \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue