mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
bpo-47164: Add _PyASCIIObject_CAST() macro (GH-32191)
Add macros to cast objects to PyASCIIObject*, PyCompactUnicodeObject* and PyUnicodeObject*: _PyASCIIObject_CAST(), _PyCompactUnicodeObject_CAST() and _PyUnicodeObject_CAST(). Using these new macros make the code more readable and check their argument with: assert(PyUnicode_Check(op)). Remove redundant assert(PyUnicode_Check(op)) in macros using directly or indirectly these new CAST macros. Replacing existing casts with these macros.
This commit is contained in:
parent
db4dada510
commit
c14d7e4b81
8 changed files with 76 additions and 78 deletions
|
@ -112,7 +112,7 @@ PyAPI_DATA(PyTypeObject) PyUnicode_Type;
|
|||
PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
|
||||
|
||||
#define PyUnicode_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
|
||||
#define PyUnicode_CheckExact(op) Py_IS_TYPE(op, &PyUnicode_Type)
|
||||
|
||||
/* --- Constants ---------------------------------------------------------- */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue