@@ -351,7 +351,7 @@ static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
351
351
kind and data pointers obtained from other function calls.
352
352
index is the index in the string (starts at 0) and value is the new
353
353
code point value which should be written to that location. */
354
- static inline void PyUnicode_WRITE (unsigned int kind, void *data,
354
+ static inline void PyUnicode_WRITE (int kind, void *data,
355
355
Py_ssize_t index, Py_UCS4 value)
356
356
{
357
357
if (kind == PyUnicode_1BYTE_KIND) {
@@ -368,12 +368,15 @@ static inline void PyUnicode_WRITE(unsigned int kind, void *data,
368
368
_Py_STATIC_CAST (Py_UCS4*, data)[index ] = value;
369
369
}
370
370
}
371
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
371
372
#define PyUnicode_WRITE (kind, data, index, value ) \
372
- PyUnicode_WRITE ((unsigned int )(kind), (void *)(data), (index), (Py_UCS4)(value))
373
+ PyUnicode_WRITE (_Py_STATIC_CAST(int , kind), _Py_CAST(void *, data), \
374
+ (index), _Py_STATIC_CAST(Py_UCS4, value))
375
+ #endif
373
376
374
377
/* Read a code point from the string's canonical representation. No checks
375
378
or ready calls are performed. */
376
- static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
379
+ static inline Py_UCS4 PyUnicode_READ (int kind,
377
380
const void *data, Py_ssize_t index)
378
381
{
379
382
if (kind == PyUnicode_1BYTE_KIND) {
@@ -385,8 +388,11 @@ static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
385
388
assert (kind == PyUnicode_4BYTE_KIND);
386
389
return _Py_STATIC_CAST (const Py_UCS4*, data)[index ];
387
390
}
391
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
388
392
#define PyUnicode_READ (kind, data, index ) \
389
- PyUnicode_READ ((unsigned int )(kind), (const void *)(data), (index))
393
+ PyUnicode_READ (_Py_STATIC_CAST(int , kind), _Py_CAST(const void *, data), \
394
+ (index))
395
+ #endif
390
396
391
397
/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it
392
398
calls PyUnicode_KIND() and might call it twice. For single reads, use
@@ -395,7 +401,7 @@ static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
395
401
static inline Py_UCS4 PyUnicode_READ_CHAR (PyObject *unicode, Py_ssize_t index)
396
402
{
397
403
assert (PyUnicode_IS_READY (unicode));
398
- unsigned int kind = PyUnicode_KIND (unicode);
404
+ int kind = PyUnicode_KIND (unicode);
399
405
if (kind == PyUnicode_1BYTE_KIND) {
400
406
return PyUnicode_1BYTE_DATA (unicode)[index ];
401
407
}
@@ -420,7 +426,7 @@ static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
420
426
return 0x7fU ;
421
427
}
422
428
423
- unsigned int kind = PyUnicode_KIND (op);
429
+ int kind = PyUnicode_KIND (op);
424
430
if (kind == PyUnicode_1BYTE_KIND) {
425
431
return 0xffU ;
426
432
}
0 commit comments