Title: Support buffer protocol with type specs
Type: enhancement Stage: patch review
Components: C API Versions: Python 3.10, Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ncoghlan, paul.moore, petr.viktorin, pitrou, scoder, skrah, vstinner
Priority: normal Keywords: patch

Created on 2020-05-22 07:51 by scoder, last changed 2020-06-05 07:45 by scoder.

Pull Requests
URL Status Linked Edit
PR 20648 open scoder, 2020-06-05 07:45
Messages (2)
msg369561 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2020-05-22 07:51
As far as I can see it in typeslots.h [1], the buffer protocol is still not supported when using type specs:

/* Disabled, see #10181 */
#undef Py_bf_getbuffer
#undef Py_bf_releasebuffer

It seems that the discussion in issue 10181 did not lead anywhere at the time (2010-2012).

I'm not talking about the limited API or the stable ABI here, I'm talking about using type specs to define an extension type. The work-around is to manually set "PyTypeObject->tp_as_buffer" after creating the type, but since PyType_Ready() then does not see that struct pointer, you also still have to make sure that the type correctly inherits the slots from the base type if you're not defining all of them yourself.

Can we just add support for the above slots?

msg370194 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2020-05-28 11:35
Yes, it should be possible to wrap them in #if so they aren't part of the stable ABI.
Date User Action Args
2020-06-05 07:45:18scodersetkeywords: + patch
stage: patch review
pull_requests: + pull_request19868
2020-05-28 11:35:09petr.viktorinsetmessages: + msg370194
2020-05-22 07:51:02scodercreate