Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner 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

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

@vstinner
Copy link
MemberAuthor

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.

@vstinnervstinner merged commit c14d7e4 into python:mainMar 31, 2022
@vstinnervstinner deleted the unicode_cast branch March 31, 2022 07:59
@vstinner
Copy link
MemberAuthor

Merged. Thanks for the review @methane.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@vstinner@methane@the-knights-who-say-ni@bedevere-bot