Skip to content

bpo-47164: Add _PyASCIIObject_CAST() macro - #32191

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:unicode_cast
Mar 31, 2022
Merged

vstinner merged 2 commits into
python:mainfrom
vstinner:unicode_cast

Conversation

@vstinner

@vstinner vstinner commented Mar 30, 2022 •

Copy link
Copy Markdown
Member

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.

https://bugs.python.org/issue47164

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.
@methane

methane commented Mar 31, 2022

Copy link
Copy Markdown
Member

It looks good to me, but I don't understand why MSVC can't compile it....

@vstinner

Copy link
Copy Markdown
Member Author

It looks good to me, but I don't understand why MSVC can't compile it....

Ah, it was a typo on a macro only used on Windows. It should be fixed now.

@vstinner
vstinner merged commit c14d7e4 into python:main Mar 31, 2022
@vstinner
vstinner deleted the unicode_cast branch March 31, 2022 07:59
@vstinner

Copy link
Copy Markdown
Member Author

Merged. Thanks for the review @methane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants