mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
_PyUnicode_CheckConsistency() also checks maxchar maximum value,
not only its minimum value
This commit is contained in:
parent
d5c4022d2a
commit
77faf69ca1
2 changed files with 17 additions and 8 deletions
|
@ -392,15 +392,21 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
|
|||
maxchar = ch;
|
||||
}
|
||||
if (kind == PyUnicode_1BYTE_KIND) {
|
||||
if (ascii->state.ascii == 0)
|
||||
if (ascii->state.ascii == 0) {
|
||||
assert(maxchar >= 128);
|
||||
assert(maxchar <= 255);
|
||||
}
|
||||
else
|
||||
assert(maxchar < 128);
|
||||
}
|
||||
else if (kind == PyUnicode_2BYTE_KIND)
|
||||
else if (kind == PyUnicode_2BYTE_KIND) {
|
||||
assert(maxchar >= 0x100);
|
||||
else
|
||||
assert(maxchar <= 0xFFFF);
|
||||
}
|
||||
else {
|
||||
assert(maxchar >= 0x10000);
|
||||
assert(maxchar <= 0x10FFFF);
|
||||
}
|
||||
}
|
||||
if (check_content && !unicode_is_singleton(op))
|
||||
assert(ascii->hash == -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue