@@ -256,14 +256,18 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
256256static inline unsigned int PyUnicode_CHECK_INTERNED (PyObject *op) {
257257 return _PyASCIIObject_CAST (op)->state .interned ;
258258}
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
260262
261263/* Fast check to determine whether an object is ready. Equivalent to:
262264 PyUnicode_IS_COMPACT(op) || _PyUnicodeObject_CAST(op)->data.any */
263265static inline unsigned int PyUnicode_IS_READY (PyObject *op) {
264266 return _PyASCIIObject_CAST (op)->state .ready ;
265267}
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
267271
268272/* Return true if the string contains only ASCII characters, or 0 if not. The
269273 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) {
272276 assert (PyUnicode_IS_READY (op));
273277 return _PyASCIIObject_CAST (op)->state .ascii ;
274278}
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
276282
277283/* Return true if the string is compact or 0 if not.
278284 No type checks or Ready calls are performed. */
279285static inline unsigned int PyUnicode_IS_COMPACT (PyObject *op) {
280286 return _PyASCIIObject_CAST (op)->state .compact ;
281287}
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
283291
284292/* Return true if the string is a compact ASCII string (use PyASCIIObject
285293 structure), or 0 if not. No type checks or Ready calls are performed. */
286294static inline int PyUnicode_IS_COMPACT_ASCII (PyObject *op) {
287295 return (_PyASCIIObject_CAST (op)->state .ascii && PyUnicode_IS_COMPACT (op));
288296}
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
290300
291301enum PyUnicode_Kind {
292302/* String contains only wstr byte characters. This is only possible
@@ -326,7 +336,9 @@ static inline void* PyUnicode_DATA(PyObject *op) {
326336 }
327337 return _PyUnicode_NONCOMPACT_DATA (op);
328338}
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
330342
331343/* Return pointers to the canonical representation cast to unsigned char,
332344 Py_UCS2, or Py_UCS4 for direct character access.
@@ -344,7 +356,9 @@ static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
344356 assert (PyUnicode_IS_READY (op));
345357 return _PyASCIIObject_CAST (op)->length ;
346358}
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
348362
349363/* Write into the canonical representation, this function does not do any sanity
350364 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)
405419 assert (kind == PyUnicode_4BYTE_KIND);
406420 return PyUnicode_4BYTE_DATA (unicode)[index];
407421}
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
410426
411427/* Return a maximum character value which is suitable for creating another
412428 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)
428444 assert (kind == PyUnicode_4BYTE_KIND);
429445 return 0x10ffffU ;
430446}
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
433451
434452/* === Public API ========================================================= */
435453
@@ -465,7 +483,9 @@ static inline int PyUnicode_READY(PyObject *op)
465483 }
466484 return _PyUnicode_Ready (op);
467485}
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
469489
470490/* Get a copy of a Unicode string. */
471491PyAPI_FUNC (PyObject*) _PyUnicode_Copy(
@@ -606,7 +626,9 @@ static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op)
606626 return _PyCompactUnicodeObject_CAST (op)->wstr_length ;
607627 }
608628}
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
610632
611633/* Returns the deprecated Py_UNICODE representation's size in code units
612634 (this includes surrogate pairs as 2 units).
@@ -625,7 +647,9 @@ static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
625647 return PyUnicode_WSTR_LENGTH (op);
626648 _Py_COMP_DIAG_POP
627649}
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
629653
630654Py_DEPRECATED (3.3 )
631655static 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)
635659 return PyUnicode_GET_SIZE (op) * Py_UNICODE_SIZE;
636660 _Py_COMP_DIAG_POP
637661}
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
639665
640666/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
641667 representation on demand. Using this macro is very inefficient now,
@@ -655,7 +681,9 @@ static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
655681 return PyUnicode_AsUnicode (op);
656682 _Py_COMP_DIAG_POP
657683}
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
659687
660688Py_DEPRECATED (3.3 )
661689static inline const char* PyUnicode_AS_DATA(PyObject *op)
@@ -665,7 +693,9 @@ static inline const char* PyUnicode_AS_DATA(PyObject *op)
665693 return (const char *)PyUnicode_AS_UNICODE (op);
666694 _Py_COMP_DIAG_POP
667695}
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
669699
670700
671701/* --- _PyUnicodeWriter API ----------------------------------------------- */
0 commit comments