bpo-45490: Convert unicodeobject.h macros to static inline functions by vstinner · Pull Request #31221 · python/cpython
* Convert unicodeobject.h macros to static inline functions.
* Reorder functions to declare functions before their first usage.
* Add "kind" variable to PyUnicode_READ_CHAR() and
PyUnicode_MAX_CHAR_VALUE() functions to only call PyUnicode_KIND()
once.
* PyUnicode_KIND() now returns an "enum PyUnicode_Kind".
* Simplify PyUnicode_GET_SIZE().
* Add assertions to PyUnicode_WRITE() on the max value.
* Add cast macros:
* _PyASCIIObject_CAST()
* _PyCompactUnicodeObject_CAST()
* _PyUnicodeObject_CAST()
* The following functions are now declared as deprecated using
Py_DEPRECATED(3.3):
* PyUnicode_GET_SIZE()
* PyUnicode_GET_DATA_SIZE()
* PyUnicode_AS_UNICODE()
* PyUnicode_AS_DATA()
* The implementation of these functions disable deprecation
warnings in their body.
* PyUnicode_READ_CHAR() now uses PyUnicode_1BYTE_DATA(),
PyUnicode_2BYTE_DATA() and PyUnicode_4BYTE_DATA().
* Replace "const PyObject*" with "PyObject*" in _decimal.c
and pystrhex.c: PyUnicode_READY() can modify the object.
* Replace "const void *data" with "void *data" in some unicodedata.c
and unicodeobject.c functions which use PyUnicode_WRITE(): data is
used to modify the string.