FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-89653: PEP 670: Convert unicodeobject.h macros to functions by vstinner · Pull Request #91705 · python/cpython · GitHub

Repository navigation

gh-89653: PEP 670: Convert unicodeobject.h macros to functions - #91705

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:unicode_macros1
Apr 21, 2022
Merged

vstinner merged 2 commits into
python:mainfrom
vstinner:unicode_macros1

Conversation

Copy link
Copy Markdown
Member

Convert unicodeobject.h macros to static inline functions:

  • PyUnicode_CHECK_INTERNED()
  • PyUnicode_DATA(), _PyUnicode_COMPACT_DATA(),
    _PyUnicode_NONCOMPACT_DATA()
  • PyUnicode_GET_LENGTH()
  • PyUnicode_IS_ASCII()
  • PyUnicode_IS_COMPACT()
  • PyUnicode_IS_COMPACT_ASCII()
  • PyUnicode_IS_READY()

Reorder functions to declare functions before their first usage.

Static inline functions are wrapped into macros which casts
"PyObject*" with _PyObject_CAST() to prevent introducing new compiler
warnings when passing "const PyObject*".

Copy link
Copy Markdown
Member Author

@erlend-aasland: Ok, here is a shorter PR.

I left the PyUnicode_KIND() macro unchanged since converting it to a static inline function introduces new compiler warning if the return type is int, but also if the return type is unsigned int! The compiler doesn't emit warnings on the macro, only with a static inline function.

Convert unicodeobject.h macros to static inline functions:

* PyUnicode_CHECK_INTERNED()
* PyUnicode_DATA(), _PyUnicode_COMPACT_DATA(),
  _PyUnicode_NONCOMPACT_DATA()
* PyUnicode_GET_LENGTH()
* PyUnicode_IS_ASCII()
* PyUnicode_IS_COMPACT()
* PyUnicode_IS_COMPACT_ASCII()
* PyUnicode_IS_READY()

Reorder functions to declare functions before their first usage.

Static inline functions are wrapped into macros which casts
"PyObject*" with _PyObject_CAST() to prevent introducing new compiler
warnings when passing "const PyObject*".

erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good! I left some small nitpick comments.

Comment thread Include/cpython/unicodeobject.h Outdated
Comment thread Include/cpython/unicodeobject.h Outdated
vstinner merged commit 4e52c66 into python:main Apr 21, 2022
vstinner deleted the unicode_macros1 branch April 21, 2022 00:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL