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

Please add getbufferproc and releasebufferproc to the limited API headers #98410

Closed
davidhewitt opened this issue Oct 18, 2022 · 2 comments
Closed
Labels
3.11 only security fixes topic-C-API type-feature A feature request or enhancement

Comments

@davidhewitt
Copy link
Contributor

Feature or enhancement

Starting with Python 3.11 the Py_Buffer API has been made available in the limited API, including the bf_getbuffer and bf_releasebuffer type slots.

However the definitions for the function pointer types stored in those slots, getbufferproc and releasebufferproc are still only defined when including "cpython" headers.

This means on the limited API starting with Python 3.11 it is now possible to do PyType_GetSlot(Py_TYPE(obj), Py_bf_getbuffer), however the void * returned does not have a function pointer type available which it can be cast to (unless the user adds this typedef themselves in their own code).

Pitch

This is a relatively straightforward change to make use of these type slots more convenient on the limited API.

I wrote an initial implementation at #31158. A couple of tiny tweaks beyond moving the typedefs was necessary so that forward definitions continued to function. Please see that PR for the detail.

@encukou
Copy link
Member

encukou commented Oct 31, 2022

Thank you!

@encukou encukou closed this as completed Oct 31, 2022
encukou pushed a commit that referenced this issue Oct 31, 2022
@vstinner
Copy link
Member

I dislike the fact that most callback types used by PyTypeObject are not prefixed by Py_ prefix, nor use the same coding style (casing) than other names used by the Python API :-(

binaryfunc, ternaryfunc, ssizeobjargproc, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants