@@ -75,7 +75,6 @@ typedef struct {
7575 * kind = PyUnicode_1BYTE_KIND
7676 * compact = 1
7777 * ascii = 1
78- * ready = 1
7978 * (length is the length of the utf8)
8079 * (data starts just after the structure)
8180 * (since ASCII is decoded from UTF-8, the utf8 string are the data)
@@ -87,20 +86,18 @@ typedef struct {
8786 * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
8887 PyUnicode_4BYTE_KIND
8988 * compact = 1
90- * ready = 1
9189 * ascii = 0
9290 * utf8 is not shared with data
9391 * utf8_length = 0 if utf8 is NULL
9492 * (data starts just after the structure)
9593
96- - legacy string, ready :
94+ - legacy string:
9795
9896 * structure = PyUnicodeObject structure
9997 * test: !PyUnicode_IS_COMPACT(op)
10098 * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
10199 PyUnicode_4BYTE_KIND
102100 * compact = 0
103- * ready = 1
104101 * data.any is not NULL
105102 * utf8 is shared and utf8_length = length with data.any if ascii = 1
106103 * utf8_length = 0 if utf8 is NULL
@@ -158,14 +155,9 @@ typedef struct {
158155 and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
159156 set, use the PyASCIIObject structure. */
160157 unsigned int ascii :1 ;
161- /* The ready flag indicates whether the object layout is initialized
162- completely. This means that this is either a compact object, or
163- the data pointer is filled out. The bit is redundant, and helps
164- to minimize the test in PyUnicode_IS_READY(). */
165- unsigned int ready :1 ;
166158 /* Padding to ensure that PyUnicode_DATA() is always aligned to
167159 4 bytes (see issue #19537 on m68k). */
168- unsigned int :24 ;
160+ unsigned int :25 ;
169161 } state ;
170162} PyASCIIObject ;
171163
@@ -223,10 +215,9 @@ static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) {
223215# define PyUnicode_CHECK_INTERNED (op ) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
224216#endif
225217
226- /* Fast check to determine whether an object is ready. Equivalent to:
227- PyUnicode_IS_COMPACT(op) || _PyUnicodeObject_CAST(op)->data.any */
218+ /* For backward compatibility */
228219static inline unsigned int PyUnicode_IS_READY (PyObject * op ) {
229- return _PyASCIIObject_CAST ( op ) -> state . ready ;
220+ return 1 ;
230221}
231222#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
232223# define PyUnicode_IS_READY (op ) PyUnicode_IS_READY(_PyObject_CAST(op))
@@ -236,7 +227,6 @@ static inline unsigned int PyUnicode_IS_READY(PyObject *op) {
236227 string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
237228 ready. */
238229static inline unsigned int PyUnicode_IS_ASCII (PyObject * op ) {
239- assert (PyUnicode_IS_READY (op ));
240230 return _PyASCIIObject_CAST (op )-> state .ascii ;
241231}
242232#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
@@ -270,8 +260,7 @@ enum PyUnicode_Kind {
270260
271261/* Return one of the PyUnicode_*_KIND values defined above. */
272262#define PyUnicode_KIND (op ) \
273- (assert(PyUnicode_IS_READY(op)), \
274- _PyASCIIObject_CAST(op)->state.kind)
263+ (_PyASCIIObject_CAST(op)->state.kind)
275264
276265/* Return a void pointer to the raw unicode buffer. */
277266static inline void * _PyUnicode_COMPACT_DATA (PyObject * op ) {
@@ -307,11 +296,8 @@ static inline void* PyUnicode_DATA(PyObject *op) {
307296#define PyUnicode_2BYTE_DATA (op ) _Py_STATIC_CAST(Py_UCS2*, PyUnicode_DATA(op))
308297#define PyUnicode_4BYTE_DATA (op ) _Py_STATIC_CAST(Py_UCS4*, PyUnicode_DATA(op))
309298
310- /* Returns the length of the unicode string. The caller has to make sure that
311- the string has it's canonical representation set before calling
312- this function. Call PyUnicode_(FAST_)Ready to ensure that. */
299+ /* Returns the length of the unicode string. */
313300static inline Py_ssize_t PyUnicode_GET_LENGTH (PyObject * op ) {
314- assert (PyUnicode_IS_READY (op ));
315301 return _PyASCIIObject_CAST (op )-> length ;
316302}
317303#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
@@ -366,7 +352,6 @@ static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
366352 cache kind and use PyUnicode_READ instead. */
367353static inline Py_UCS4 PyUnicode_READ_CHAR (PyObject * unicode , Py_ssize_t index )
368354{
369- assert (PyUnicode_IS_READY (unicode ));
370355 unsigned int kind = PyUnicode_KIND (unicode );
371356 if (kind == PyUnicode_1BYTE_KIND ) {
372357 return PyUnicode_1BYTE_DATA (unicode )[index ];
@@ -387,7 +372,6 @@ static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)
387372 than iterating over the string. */
388373static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE (PyObject * op )
389374{
390- assert (PyUnicode_IS_READY (op ));
391375 if (PyUnicode_IS_ASCII (op )) {
392376 return 0x7fU ;
393377 }
@@ -419,13 +403,9 @@ PyAPI_FUNC(PyObject*) PyUnicode_New(
419403 Py_UCS4 maxchar /* maximum code point value in the string */
420404 );
421405
422- /* PyUnicode_READY() does less work than _PyUnicode_Ready() in the best
423- case. If the canonical representation is not yet set, it will still call
424- _PyUnicode_Ready().
425- Returns 0 on success and -1 on errors. */
406+ /* For backward compatibility */
426407static inline int PyUnicode_READY (PyObject * op )
427408{
428- assert (PyUnicode_IS_READY (op ));
429409 return 0 ;
430410}
431411#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
@@ -574,8 +554,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
574554
575555 Return 0 on success, raise an exception and return -1 on error. */
576556#define _PyUnicodeWriter_PrepareKind (WRITER , KIND ) \
577- (assert((KIND) != PyUnicode_WCHAR_KIND), \
578- (KIND) <= (WRITER)->kind \
557+ ((KIND) <= (WRITER)->kind \
579558 ? 0 \
580559 : _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND)))
581560
0 commit comments