Skip to content

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

Closed
@davidhewitt

Description

@davidhewitt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions