@@ -188,45 +188,35 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
188
188
static inline unsigned int PyUnicode_CHECK_INTERNED (PyObject * op ) {
189
189
return _PyASCIIObject_CAST (op )-> state .interned ;
190
190
}
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))
194
192
195
193
/* For backward compatibility */
196
194
static inline unsigned int PyUnicode_IS_READY (PyObject * Py_UNUSED (op )) {
197
195
return 1 ;
198
196
}
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))
202
198
203
199
/* Return true if the string contains only ASCII characters, or 0 if not. The
204
200
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
205
201
ready. */
206
202
static inline unsigned int PyUnicode_IS_ASCII (PyObject * op ) {
207
203
return _PyASCIIObject_CAST (op )-> state .ascii ;
208
204
}
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))
212
206
213
207
/* Return true if the string is compact or 0 if not.
214
208
No type checks or Ready calls are performed. */
215
209
static inline unsigned int PyUnicode_IS_COMPACT (PyObject * op ) {
216
210
return _PyASCIIObject_CAST (op )-> state .compact ;
217
211
}
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))
221
213
222
214
/* Return true if the string is a compact ASCII string (use PyASCIIObject
223
215
structure), or 0 if not. No type checks or Ready calls are performed. */
224
216
static inline int PyUnicode_IS_COMPACT_ASCII (PyObject * op ) {
225
217
return (_PyASCIIObject_CAST (op )-> state .ascii && PyUnicode_IS_COMPACT (op ));
226
218
}
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))
230
220
231
221
enum PyUnicode_Kind {
232
222
/* Return values of the PyUnicode_KIND() function: */
@@ -236,22 +226,14 @@ enum PyUnicode_Kind {
236
226
};
237
227
238
228
// PyUnicode_KIND(): Return one of the PyUnicode_*_KIND values defined above.
239
- #if !defined( Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030c0000
229
+ //
240
230
// gh-89653: Converting this macro to a static inline function would introduce
241
231
// new compiler warnings on "kind < PyUnicode_KIND(str)" (compare signed and
242
232
// unsigned numbers) where kind type is an int or on
243
233
// "unsigned int kind = PyUnicode_KIND(str)" (cast signed to unsigned).
244
234
// Only declare the function as static inline function in the limited C API
245
235
// 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)
255
237
256
238
/* Return a void pointer to the raw unicode buffer. */
257
239
static inline void * _PyUnicode_COMPACT_DATA (PyObject * op ) {
@@ -275,9 +257,7 @@ static inline void* PyUnicode_DATA(PyObject *op) {
275
257
}
276
258
return _PyUnicode_NONCOMPACT_DATA (op );
277
259
}
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))
281
261
282
262
/* Return pointers to the canonical representation cast to unsigned char,
283
263
Py_UCS2, or Py_UCS4 for direct character access.
@@ -292,9 +272,7 @@ static inline void* PyUnicode_DATA(PyObject *op) {
292
272
static inline Py_ssize_t PyUnicode_GET_LENGTH (PyObject * op ) {
293
273
return _PyASCIIObject_CAST (op )-> length ;
294
274
}
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))
298
276
299
277
/* Write into the canonical representation, this function does not do any sanity
300
278
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,
319
297
_Py_STATIC_CAST (Py_UCS4 * , data ) [index ] = value ;
320
298
}
321
299
}
322
- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
323
300
#define PyUnicode_WRITE (kind , data , index , value ) \
324
301
PyUnicode_WRITE(_Py_STATIC_CAST(int, kind), _Py_CAST(void*, data), \
325
302
(index), _Py_STATIC_CAST(Py_UCS4, value))
326
- #endif
327
303
328
304
/* Read a code point from the string's canonical representation. No checks
329
305
or ready calls are performed. */
@@ -340,12 +316,10 @@ static inline Py_UCS4 PyUnicode_READ(int kind,
340
316
assert (kind == PyUnicode_4BYTE_KIND );
341
317
return _Py_STATIC_CAST (const Py_UCS4 * , data )[index ];
342
318
}
343
- #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
344
319
#define PyUnicode_READ (kind , data , index ) \
345
320
PyUnicode_READ(_Py_STATIC_CAST(int, kind), \
346
321
_Py_STATIC_CAST(const void*, data), \
347
322
(index))
348
- #endif
349
323
350
324
/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it
351
325
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)
369
343
assert (kind == PyUnicode_4BYTE_KIND );
370
344
return PyUnicode_4BYTE_DATA (unicode )[index ];
371
345
}
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))
376
348
377
349
/* Return a maximum character value which is suitable for creating another
378
350
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)
395
367
assert (kind == PyUnicode_4BYTE_KIND );
396
368
return 0x10ffffU ;
397
369
}
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))
402
372
403
373
/* === Public API ========================================================= */
404
374
@@ -417,9 +387,7 @@ static inline int PyUnicode_READY(PyObject* Py_UNUSED(op))
417
387
{
418
388
return 0 ;
419
389
}
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))
423
391
424
392
/* Get a copy of a Unicode string. */
425
393
PyAPI_FUNC (PyObject * ) _PyUnicode_Copy (
0 commit comments