@@ -256,14 +256,18 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
256
256
static inline unsigned int PyUnicode_CHECK_INTERNED (PyObject *op) {
257
257
return _PyASCIIObject_CAST (op)->state .interned ;
258
258
}
259
- #define PyUnicode_CHECK_INTERNED (op ) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
259
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
260
+ # define PyUnicode_CHECK_INTERNED (op ) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
261
+ #endif
260
262
261
263
/* Fast check to determine whether an object is ready. Equivalent to:
262
264
PyUnicode_IS_COMPACT(op) || _PyUnicodeObject_CAST(op)->data.any */
263
265
static inline unsigned int PyUnicode_IS_READY (PyObject *op) {
264
266
return _PyASCIIObject_CAST (op)->state .ready ;
265
267
}
266
- #define PyUnicode_IS_READY (op ) PyUnicode_IS_READY(_PyObject_CAST(op))
268
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
269
+ # define PyUnicode_IS_READY (op ) PyUnicode_IS_READY(_PyObject_CAST(op))
270
+ #endif
267
271
268
272
/* Return true if the string contains only ASCII characters, or 0 if not. The
269
273
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
@@ -272,21 +276,27 @@ static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) {
272
276
assert (PyUnicode_IS_READY (op));
273
277
return _PyASCIIObject_CAST (op)->state .ascii ;
274
278
}
275
- #define PyUnicode_IS_ASCII (op ) PyUnicode_IS_ASCII(_PyObject_CAST(op))
279
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
280
+ # define PyUnicode_IS_ASCII (op ) PyUnicode_IS_ASCII(_PyObject_CAST(op))
281
+ #endif
276
282
277
283
/* Return true if the string is compact or 0 if not.
278
284
No type checks or Ready calls are performed. */
279
285
static inline unsigned int PyUnicode_IS_COMPACT (PyObject *op) {
280
286
return _PyASCIIObject_CAST (op)->state .compact ;
281
287
}
282
- #define PyUnicode_IS_COMPACT (op ) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
288
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
289
+ # define PyUnicode_IS_COMPACT (op ) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
290
+ #endif
283
291
284
292
/* Return true if the string is a compact ASCII string (use PyASCIIObject
285
293
structure), or 0 if not. No type checks or Ready calls are performed. */
286
294
static inline int PyUnicode_IS_COMPACT_ASCII (PyObject *op) {
287
295
return (_PyASCIIObject_CAST (op)->state .ascii && PyUnicode_IS_COMPACT (op));
288
296
}
289
- #define PyUnicode_IS_COMPACT_ASCII (op ) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
297
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
298
+ # define PyUnicode_IS_COMPACT_ASCII (op ) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
299
+ #endif
290
300
291
301
enum PyUnicode_Kind {
292
302
/* String contains only wstr byte characters. This is only possible
@@ -326,7 +336,9 @@ static inline void* PyUnicode_DATA(PyObject *op) {
326
336
}
327
337
return _PyUnicode_NONCOMPACT_DATA (op);
328
338
}
329
- #define PyUnicode_DATA (op ) PyUnicode_DATA(_PyObject_CAST(op))
339
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
340
+ # define PyUnicode_DATA (op ) PyUnicode_DATA(_PyObject_CAST(op))
341
+ #endif
330
342
331
343
/* Return pointers to the canonical representation cast to unsigned char,
332
344
Py_UCS2, or Py_UCS4 for direct character access.
@@ -344,7 +356,9 @@ static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
344
356
assert (PyUnicode_IS_READY (op));
345
357
return _PyASCIIObject_CAST (op)->length ;
346
358
}
347
- #define PyUnicode_GET_LENGTH (op ) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
359
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
360
+ # define PyUnicode_GET_LENGTH (op ) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
361
+ #endif
348
362
349
363
/* Write into the canonical representation, this function does not do any sanity
350
364
checks and is intended for usage in loops. The caller should cache the
@@ -405,8 +419,10 @@ static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)
405
419
assert (kind == PyUnicode_4BYTE_KIND);
406
420
return PyUnicode_4BYTE_DATA (unicode)[index ];
407
421
}
408
- #define PyUnicode_READ_CHAR (unicode, index ) \
409
- PyUnicode_READ_CHAR (_PyObject_CAST(unicode), (index))
422
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
423
+ # define PyUnicode_READ_CHAR (unicode, index ) \
424
+ PyUnicode_READ_CHAR (_PyObject_CAST(unicode), (index))
425
+ #endif
410
426
411
427
/* Return a maximum character value which is suitable for creating another
412
428
string based on op. This is always an approximation but more efficient
@@ -428,8 +444,10 @@ static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
428
444
assert (kind == PyUnicode_4BYTE_KIND);
429
445
return 0x10ffffU ;
430
446
}
431
- #define PyUnicode_MAX_CHAR_VALUE (op ) \
432
- PyUnicode_MAX_CHAR_VALUE (_PyObject_CAST(op))
447
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
448
+ # define PyUnicode_MAX_CHAR_VALUE (op ) \
449
+ PyUnicode_MAX_CHAR_VALUE (_PyObject_CAST(op))
450
+ #endif
433
451
434
452
/* === Public API ========================================================= */
435
453
@@ -465,7 +483,9 @@ static inline int PyUnicode_READY(PyObject *op)
465
483
}
466
484
return _PyUnicode_Ready (op);
467
485
}
468
- #define PyUnicode_READY (op ) PyUnicode_READY(_PyObject_CAST(op))
486
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
487
+ # define PyUnicode_READY (op ) PyUnicode_READY(_PyObject_CAST(op))
488
+ #endif
469
489
470
490
/* Get a copy of a Unicode string. */
471
491
PyAPI_FUNC (PyObject*) _PyUnicode_Copy(
@@ -606,7 +626,9 @@ static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op)
606
626
return _PyCompactUnicodeObject_CAST (op)->wstr_length ;
607
627
}
608
628
}
609
- #define PyUnicode_WSTR_LENGTH (op ) PyUnicode_WSTR_LENGTH(_PyObject_CAST(op))
629
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
630
+ # define PyUnicode_WSTR_LENGTH (op ) PyUnicode_WSTR_LENGTH(_PyObject_CAST(op))
631
+ #endif
610
632
611
633
/* Returns the deprecated Py_UNICODE representation's size in code units
612
634
(this includes surrogate pairs as 2 units).
@@ -625,7 +647,9 @@ static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
625
647
return PyUnicode_WSTR_LENGTH (op);
626
648
_Py_COMP_DIAG_POP
627
649
}
628
- #define PyUnicode_GET_SIZE (op ) PyUnicode_GET_SIZE(_PyObject_CAST(op))
650
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
651
+ # define PyUnicode_GET_SIZE (op ) PyUnicode_GET_SIZE(_PyObject_CAST(op))
652
+ #endif
629
653
630
654
Py_DEPRECATED (3.3 )
631
655
static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
@@ -635,7 +659,9 @@ static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
635
659
return PyUnicode_GET_SIZE (op) * Py_UNICODE_SIZE;
636
660
_Py_COMP_DIAG_POP
637
661
}
638
- #define PyUnicode_GET_DATA_SIZE (op ) PyUnicode_GET_DATA_SIZE(_PyObject_CAST(op))
662
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
663
+ # define PyUnicode_GET_DATA_SIZE (op ) PyUnicode_GET_DATA_SIZE(_PyObject_CAST(op))
664
+ #endif
639
665
640
666
/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
641
667
representation on demand. Using this macro is very inefficient now,
@@ -655,7 +681,9 @@ static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
655
681
return PyUnicode_AsUnicode (op);
656
682
_Py_COMP_DIAG_POP
657
683
}
658
- #define PyUnicode_AS_UNICODE (op ) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
684
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
685
+ # define PyUnicode_AS_UNICODE (op ) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
686
+ #endif
659
687
660
688
Py_DEPRECATED (3.3 )
661
689
static inline const char* PyUnicode_AS_DATA(PyObject *op)
@@ -665,7 +693,9 @@ static inline const char* PyUnicode_AS_DATA(PyObject *op)
665
693
return (const char *)PyUnicode_AS_UNICODE (op);
666
694
_Py_COMP_DIAG_POP
667
695
}
668
- #define PyUnicode_AS_DATA (op ) PyUnicode_AS_DATA(_PyObject_CAST(op))
696
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
697
+ # define PyUnicode_AS_DATA (op ) PyUnicode_AS_DATA(_PyObject_CAST(op))
698
+ #endif
669
699
670
700
671
701
/* --- _PyUnicodeWriter API ----------------------------------------------- */
0 commit comments