Commit 24c74be9 authored by Victor Stinner's avatar Victor Stinner

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.
parent c4b49549
...@@ -424,10 +424,12 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; ...@@ -424,10 +424,12 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
#define SSTATE_INTERNED_IMMORTAL 2 #define SSTATE_INTERNED_IMMORTAL 2
/* Return true if the string contains only ASCII characters, or 0 if not. The /* 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 string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
or Ready calls are performed. */ ready. */
#define PyUnicode_IS_ASCII(op) \ #define PyUnicode_IS_ASCII(op) \
(((PyASCIIObject*)op)->state.ascii) (assert(PyUnicode_Check(op)), \
assert(PyUnicode_IS_READY(op)), \
((PyASCIIObject*)op)->state.ascii)
/* Return true if the string is compact or 0 if not. /* Return true if the string is compact or 0 if not.
No type checks or Ready calls are performed. */ No type checks or Ready calls are performed. */
...@@ -437,7 +439,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; ...@@ -437,7 +439,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
/* Return true if the string is a compact ASCII string (use PyASCIIObject /* 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. */ structure), or 0 if not. No type checks or Ready calls are performed. */
#define PyUnicode_IS_COMPACT_ASCII(op) \ #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 { enum PyUnicode_Kind {
/* String contains only wstr byte characters. This is only possible /* String contains only wstr byte characters. This is only possible
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment