diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-04 00:00:20 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-04 00:00:20 +0200 |
commit | 7f11ad4594f63dec8cd18a16243fb58cf0e9589b (patch) | |
tree | d5c81289d92b0bed367d1c4b147e50d022ac7662 /Objects/unicodeobject.c | |
parent | 03490918b7810341b7cdf53e5a45798ad4b6c61e (diff) | |
download | cpython-git-7f11ad4594f63dec8cd18a16243fb58cf0e9589b.tar.gz |
Unicode: document when the wstr pointer is shared with data
Add also related assertions to _PyUnicode_CheckConsistency().
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 77cc0820f9..46578128bf 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -302,12 +302,24 @@ _PyUnicode_CheckConsistency(void *op) } else if (ascii->state.compact == 1) { PyCompactUnicodeObject *compact = (PyCompactUnicodeObject *)op; + void *data; 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)); + data = compact + 1; + assert (compact->utf8 != data); + if ( +#if SIZEOF_WCHAR_T == 2 + kind == PyUnicode_2BYTE_KIND +#else + kind == PyUnicode_4BYTE_KIND +#endif + ) + assert(ascii->wstr == data); + else + assert(ascii->wstr != data); } else { PyCompactUnicodeObject *compact = (PyCompactUnicodeObject *)op; PyUnicodeObject *unicode = (PyUnicodeObject *)op; @@ -332,6 +344,16 @@ _PyUnicode_CheckConsistency(void *op) assert (compact->utf8 == unicode->data.any); else assert (compact->utf8 != unicode->data.any); + if ( +#if SIZEOF_WCHAR_T == 2 + kind == PyUnicode_2BYTE_KIND +#else + kind == PyUnicode_4BYTE_KIND +#endif + ) + assert(ascii->wstr == unicode->data.any); + else + assert(ascii->wstr != unicode->data.any); } } return 1; |