@@ -367,7 +367,7 @@ static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
367
367
kind and data pointers obtained from other function calls.
368
368
index is the index in the string (starts at 0) and value is the new
369
369
code point value which should be written to that location. */
370
- static inline void PyUnicode_WRITE (unsigned int kind, void *data,
370
+ static inline void PyUnicode_WRITE (int kind, void *data,
371
371
Py_ssize_t index, Py_UCS4 value)
372
372
{
373
373
if (kind == PyUnicode_1BYTE_KIND) {
@@ -384,12 +384,15 @@ static inline void PyUnicode_WRITE(unsigned int kind, void *data,
384
384
_Py_STATIC_CAST (Py_UCS4*, data)[index ] = value;
385
385
}
386
386
}
387
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
387
388
#define PyUnicode_WRITE (kind, data, index, value ) \
388
- PyUnicode_WRITE ((unsigned int )(kind), (void *)(data), (index), (Py_UCS4)(value))
389
+ PyUnicode_WRITE (_Py_STATIC_CAST(int , kind), _Py_CAST(void *, data), \
390
+ (index), _Py_STATIC_CAST(Py_UCS4, value))
391
+ #endif
389
392
390
393
/* Read a code point from the string's canonical representation. No checks
391
394
or ready calls are performed. */
392
- static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
395
+ static inline Py_UCS4 PyUnicode_READ (int kind,
393
396
const void *data, Py_ssize_t index)
394
397
{
395
398
if (kind == PyUnicode_1BYTE_KIND) {
@@ -401,8 +404,11 @@ static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
401
404
assert (kind == PyUnicode_4BYTE_KIND);
402
405
return _Py_STATIC_CAST (const Py_UCS4*, data)[index ];
403
406
}
407
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
404
408
#define PyUnicode_READ (kind, data, index ) \
405
- PyUnicode_READ ((unsigned int )(kind), (const void *)(data), (index))
409
+ PyUnicode_READ (_Py_STATIC_CAST(int , kind), _Py_CAST(const void *, data), \
410
+ (index))
411
+ #endif
406
412
407
413
/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it
408
414
calls PyUnicode_KIND() and might call it twice. For single reads, use
@@ -411,7 +417,7 @@ static inline Py_UCS4 PyUnicode_READ(unsigned int kind,
411
417
static inline Py_UCS4 PyUnicode_READ_CHAR (PyObject *unicode, Py_ssize_t index)
412
418
{
413
419
assert (PyUnicode_IS_READY (unicode));
414
- unsigned int kind = PyUnicode_KIND (unicode);
420
+ int kind = PyUnicode_KIND (unicode);
415
421
if (kind == PyUnicode_1BYTE_KIND) {
416
422
return PyUnicode_1BYTE_DATA (unicode)[index ];
417
423
}
@@ -436,7 +442,7 @@ static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
436
442
return 0x7fU ;
437
443
}
438
444
439
- unsigned int kind = PyUnicode_KIND (op);
445
+ int kind = PyUnicode_KIND (op);
440
446
if (kind == PyUnicode_1BYTE_KIND) {
441
447
return 0xffU ;
442
448
}
0 commit comments