_PyUnicode_CheckConsistency() also checks maxchar maximum value,

not only its minimum value
This commit is contained in:
Victor Stinner 2011-11-20 18:56:05 +01:00
parent d5c4022d2a
commit 77faf69ca1
2 changed files with 17 additions and 8 deletions

View file

@ -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);