Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 72617:ec481f3f79cd
_PyUnicode_CheckConsistency() checks utf8 field consistency
| author | Victor Stinner <vstinner@wyplay.com> |
|---|---|
| date | Mon, 03 Oct 2011 14:42:39 +0200 |
| parents | 54d77a25736d |
| children | 6fbc5e9141fc |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Mon Oct 03 14:42:15 2011 +0200 +++ b/Objects/unicodeobject.c Mon Oct 03 14:42:39 2011 +0200 @@ -293,11 +293,13 @@ assert(ascii->state.ready == 1); } else if (ascii->state.compact == 1) { + PyCompactUnicodeObject *compact = (PyCompactUnicodeObject *)op; assert(kind == PyUnicode_1BYTE_KIND || kind == PyUnicode_2BYTE_KIND || kind == PyUnicode_4BYTE_KIND); assert(ascii->state.ascii == 0); assert(ascii->state.ready == 1); + assert (compact->utf8 != (void*)(compact + 1)); } else { PyCompactUnicodeObject *compact = (PyCompactUnicodeObject *)op; PyUnicodeObject *unicode = (PyUnicodeObject *)op; @@ -318,6 +320,10 @@ assert(ascii->state.compact == 0); assert(ascii->state.ready == 1); assert(unicode->data.any != NULL); + if (ascii->state.ascii) + assert (compact->utf8 == unicode->data.any); + else + assert (compact->utf8 != unicode->data.any); } } return 1;
