Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 30, 2022

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
Copy link
Member

methane commented Mar 31, 2022

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

@vstinner
Copy link
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
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants