Skip to content

Conversation

@vstinner
Copy link
Member

Convert the following macros to static inline functions:

  • PyByteArray_AS_STRING()
  • PyByteArray_GET_SIZE()
  • PyBytes_AS_STRING()
  • PyBytes_GET_SIZE()

Limited C API version 3.11 no longer casts arguments.

Add _PyBytes_CAST() and _PyByteArray_CAST() macros.

@vstinner
Copy link
Member Author

cc @erlend-aasland

Comment on lines 17 to 19
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not write this out in the static inline functions? Ditto for _PyBytes_CAST.

Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose of this macro is to cast to PyByteArrayObject*. If it's converted to a function, what would be the argument type? How do you prevent introducing new compiler warnings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, this is fine.

Convert the following macros to static inline functions:

* PyByteArray_AS_STRING()
* PyByteArray_GET_SIZE()
* PyBytes_AS_STRING()
* PyBytes_GET_SIZE()

Limited C API version 3.11 no longer casts arguments.

Add _PyBytes_CAST() and _PyByteArray_CAST() macros.
@vstinner
Copy link
Member Author

vstinner commented May 3, 2022

I rebased my PR to get the renamed _Py_CAST() macro. I addressed @erlend-aasland's review.

@vstinner vstinner merged commit 2eca5da into python:main May 3, 2022
@vstinner vstinner deleted the pybytes_func branch May 3, 2022 18:15
@vstinner
Copy link
Member Author

vstinner commented May 3, 2022

Thanks for the review @erlend-aasland.

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