]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-47164: Add _PyASCIIObject_CAST() macro (GH-32191)
authorVictor Stinner <vstinner@python.org>
Thu, 31 Mar 2022 07:59:27 +0000 (09:59 +0200)
committerGitHub <noreply@github.com>
Thu, 31 Mar 2022 07:59:27 +0000 (09:59 +0200)
commitc14d7e4b816134b8e93ece4066a86d229631ce96
tree6b2ac5b9c3e502d77d1ff05bdcc88e918dba1ad4
parentdb4dada5108dd49ebca23e4559a53630a2df8447
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.
Include/cpython/unicodeobject.h
Include/unicodeobject.h
Modules/_collectionsmodule.c
Objects/dictobject.c
Objects/setobject.c
Objects/typeobject.c
Objects/unicodeobject.c
Python/traceback.c