@@ -188,45 +188,35 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
188188static inline unsigned int PyUnicode_CHECK_INTERNED (PyObject * op ) {
189189 return _PyASCIIObject_CAST (op )-> state .interned ;
190190}
191- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
192- # define PyUnicode_CHECK_INTERNED (op ) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
193- #endif
191+ #define PyUnicode_CHECK_INTERNED (op ) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
194192
195193/* For backward compatibility */
196194static inline unsigned int PyUnicode_IS_READY (PyObject * Py_UNUSED (op )) {
197195 return 1 ;
198196}
199- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
200- # define PyUnicode_IS_READY (op ) PyUnicode_IS_READY(_PyObject_CAST(op))
201- #endif
197+ #define PyUnicode_IS_READY (op ) PyUnicode_IS_READY(_PyObject_CAST(op))
202198
203199/* Return true if the string contains only ASCII characters, or 0 if not. The
204200 string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
205201 ready. */
206202static inline unsigned int PyUnicode_IS_ASCII (PyObject * op ) {
207203 return _PyASCIIObject_CAST (op )-> state .ascii ;
208204}
209- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
210- # define PyUnicode_IS_ASCII (op ) PyUnicode_IS_ASCII(_PyObject_CAST(op))
211- #endif
205+ #define PyUnicode_IS_ASCII (op ) PyUnicode_IS_ASCII(_PyObject_CAST(op))
212206
213207/* Return true if the string is compact or 0 if not.
214208 No type checks or Ready calls are performed. */
215209static inline unsigned int PyUnicode_IS_COMPACT (PyObject * op ) {
216210 return _PyASCIIObject_CAST (op )-> state .compact ;
217211}
218- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
219- # define PyUnicode_IS_COMPACT (op ) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
220- #endif
212+ #define PyUnicode_IS_COMPACT (op ) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
221213
222214/* Return true if the string is a compact ASCII string (use PyASCIIObject
223215 structure), or 0 if not. No type checks or Ready calls are performed. */
224216static inline int PyUnicode_IS_COMPACT_ASCII (PyObject * op ) {
225217 return (_PyASCIIObject_CAST (op )-> state .ascii && PyUnicode_IS_COMPACT (op ));
226218}
227- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
228- # define PyUnicode_IS_COMPACT_ASCII (op ) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
229- #endif
219+ #define PyUnicode_IS_COMPACT_ASCII (op ) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
230220
231221enum PyUnicode_Kind {
232222/* Return values of the PyUnicode_KIND() function: */
@@ -236,22 +226,14 @@ enum PyUnicode_Kind {
236226};
237227
238228// PyUnicode_KIND(): Return one of the PyUnicode_*_KIND values defined above.
239- #if !defined( Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030c0000
229+ //
240230// gh-89653: Converting this macro to a static inline function would introduce
241231// new compiler warnings on "kind < PyUnicode_KIND(str)" (compare signed and
242232// unsigned numbers) where kind type is an int or on
243233// "unsigned int kind = PyUnicode_KIND(str)" (cast signed to unsigned).
244234// Only declare the function as static inline function in the limited C API
245235// version 3.12 which is stricter.
246- #define PyUnicode_KIND (op ) \
247- (_PyASCIIObject_CAST(op)->state.kind)
248- #else
249- // Limited C API 3.12 and newer
250- static inline int PyUnicode_KIND (PyObject * op ) {
251- assert (PyUnicode_IS_READY (op ));
252- return _PyASCIIObject_CAST (op )-> state .kind ;
253- }
254- #endif
236+ #define PyUnicode_KIND (op ) (_PyASCIIObject_CAST(op)->state.kind)
255237
256238/* Return a void pointer to the raw unicode buffer. */
257239static inline void * _PyUnicode_COMPACT_DATA (PyObject * op ) {
@@ -275,9 +257,7 @@ static inline void* PyUnicode_DATA(PyObject *op) {
275257 }
276258 return _PyUnicode_NONCOMPACT_DATA (op );
277259}
278- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
279- # define PyUnicode_DATA (op ) PyUnicode_DATA(_PyObject_CAST(op))
280- #endif
260+ #define PyUnicode_DATA (op ) PyUnicode_DATA(_PyObject_CAST(op))
281261
282262/* Return pointers to the canonical representation cast to unsigned char,
283263 Py_UCS2, or Py_UCS4 for direct character access.
@@ -292,9 +272,7 @@ static inline void* PyUnicode_DATA(PyObject *op) {
292272static inline Py_ssize_t PyUnicode_GET_LENGTH (PyObject * op ) {
293273 return _PyASCIIObject_CAST (op )-> length ;
294274}
295- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
296- # define PyUnicode_GET_LENGTH (op ) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
297- #endif
275+ #define PyUnicode_GET_LENGTH (op ) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
298276
299277/* Write into the canonical representation, this function does not do any sanity
300278 checks and is intended for usage in loops. The caller should cache the
@@ -319,11 +297,9 @@ static inline void PyUnicode_WRITE(int kind, void *data,
319297 _Py_STATIC_CAST (Py_UCS4 * , data ) [index ] = value ;
320298 }
321299}
322- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
323300#define PyUnicode_WRITE (kind , data , index , value ) \
324301 PyUnicode_WRITE(_Py_STATIC_CAST(int, kind), _Py_CAST(void*, data), \
325302 (index), _Py_STATIC_CAST(Py_UCS4, value))
326- #endif
327303
328304/* Read a code point from the string's canonical representation. No checks
329305 or ready calls are performed. */
@@ -340,12 +316,10 @@ static inline Py_UCS4 PyUnicode_READ(int kind,
340316 assert (kind == PyUnicode_4BYTE_KIND );
341317 return _Py_STATIC_CAST (const Py_UCS4 * , data )[index ];
342318}
343- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
344319#define PyUnicode_READ (kind , data , index ) \
345320 PyUnicode_READ(_Py_STATIC_CAST(int, kind), \
346321 _Py_STATIC_CAST(const void*, data), \
347322 (index))
348- #endif
349323
350324/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it
351325 calls PyUnicode_KIND() and might call it twice. For single reads, use
@@ -369,10 +343,8 @@ static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)
369343 assert (kind == PyUnicode_4BYTE_KIND );
370344 return PyUnicode_4BYTE_DATA (unicode )[index ];
371345}
372- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
373- # define PyUnicode_READ_CHAR (unicode , index ) \
374- PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index))
375- #endif
346+ #define PyUnicode_READ_CHAR (unicode , index ) \
347+ PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index))
376348
377349/* Return a maximum character value which is suitable for creating another
378350 string based on op. This is always an approximation but more efficient
@@ -395,10 +367,8 @@ static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
395367 assert (kind == PyUnicode_4BYTE_KIND );
396368 return 0x10ffffU ;
397369}
398- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
399- # define PyUnicode_MAX_CHAR_VALUE (op ) \
400- PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op))
401- #endif
370+ #define PyUnicode_MAX_CHAR_VALUE (op ) \
371+ PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op))
402372
403373/* === Public API ========================================================= */
404374
@@ -417,9 +387,7 @@ static inline int PyUnicode_READY(PyObject* Py_UNUSED(op))
417387{
418388 return 0 ;
419389}
420- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
421- # define PyUnicode_READY (op ) PyUnicode_READY(_PyObject_CAST(op))
422- #endif
390+ #define PyUnicode_READY (op ) PyUnicode_READY(_PyObject_CAST(op))
423391
424392/* Get a copy of a Unicode string. */
425393PyAPI_FUNC (PyObject * ) _PyUnicode_Copy (
0 commit comments