Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-47164: Add _PyASCIIObject_CAST() macro #32191

Merged
merged 2 commits into from
Mar 31, 2022
Merged

bpo-47164: Add _PyASCIIObject_CAST() macro #32191

merged 2 commits into from
Mar 31, 2022

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