diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-12 00:24:20 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-12 00:24:20 (GMT) |
commit | 24c74be9a3b6b10dcd153d1c214013a7fd43b735 (patch) | |
tree | 91cd81091dc5783cedceaf86f1f572264931eb38 /Include/unicodeobject.h | |
parent | c4b495497a4ebaf856d3c2e1914c2efa09cddda2 (diff) | |
download | cpython-24c74be9a3b6b10dcd153d1c214013a7fd43b735.zip cpython-24c74be9a3b6b10dcd153d1c214013a7fd43b735.tar.gz cpython-24c74be9a3b6b10dcd153d1c214013a7fd43b735.tar.bz2 |
PyUnicode_IS_ASCII() macro ensures that the string is ready
It has no sense to check if a not ready string is ASCII or not.
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r-- | Include/unicodeobject.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 836bafb..ecf8386 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -424,10 +424,12 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; #define SSTATE_INTERNED_IMMORTAL 2 /* Return true if the string contains only ASCII characters, or 0 if not. The - string may be compact (PyUnicode_IS_COMPACT_ASCII) or not. No type checks - or Ready calls are performed. */ -#define PyUnicode_IS_ASCII(op) \ - (((PyASCIIObject*)op)->state.ascii) + string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be + ready. */ +#define PyUnicode_IS_ASCII(op) \ + (assert(PyUnicode_Check(op)), \ + assert(PyUnicode_IS_READY(op)), \ + ((PyASCIIObject*)op)->state.ascii) /* Return true if the string is compact or 0 if not. No type checks or Ready calls are performed. */ @@ -437,7 +439,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; /* Return true if the string is a compact ASCII string (use PyASCIIObject structure), or 0 if not. No type checks or Ready calls are performed. */ #define PyUnicode_IS_COMPACT_ASCII(op) \ - (PyUnicode_IS_ASCII(op) && PyUnicode_IS_COMPACT(op)) + (((PyASCIIObject*)op)->state.ascii && PyUnicode_IS_COMPACT(op)) enum PyUnicode_Kind { /* String contains only wstr byte characters. This is only possible |