Old Buffer Protocol

Αποσύρθηκε στην έκδοση 3.0.

These functions were part of the «old buffer protocol» API in Python 2.In Python 3, this protocol doesn’t exist anymore but the functions are stillexposed to ease porting 2.x code. They act as a compatibility wrapperaround thenew buffer protocol, but they don’t giveyou control over the lifetime of the resources acquired when a buffer isexported.

Therefore, it is recommended that you callPyObject_GetBuffer()(or they* orw*format codes with thePyArg_ParseTuple() family of functions) to get a buffer view overan object, andPyBuffer_Release() when the buffer view can be released.

intPyObject_AsCharBuffer(PyObject*obj,constchar**buffer,Py_ssize_t*buffer_len)
Μέρος τουΣταθερό ABI.

Returns a pointer to a read-only memory location usable as character-basedinput. Theobj argument must support the single-segment character bufferinterface. On success, returns0, setsbuffer to the memory locationandbuffer_len to the buffer length. Returns-1 and sets aTypeError on error.

intPyObject_AsReadBuffer(PyObject*obj,constvoid**buffer,Py_ssize_t*buffer_len)
Μέρος τουΣταθερό ABI.

Returns a pointer to a read-only memory location containing arbitrary data.Theobj argument must support the single-segment readable bufferinterface. On success, returns0, setsbuffer to the memory locationandbuffer_len to the buffer length. Returns-1 and sets aTypeError on error.

intPyObject_CheckReadBuffer(PyObject*o)
Μέρος τουΣταθερό ABI.

Returns1 ifo supports the single-segment readable buffer interface.Otherwise returns0. This function always succeeds.

Note that this function tries to get and release a buffer, and exceptionswhich occur while calling corresponding functions will get suppressed.To get error reporting usePyObject_GetBuffer() instead.

intPyObject_AsWriteBuffer(PyObject*obj,void**buffer,Py_ssize_t*buffer_len)
Μέρος τουΣταθερό ABI.

Returns a pointer to a writable memory location. Theobj argument mustsupport the single-segment, character buffer interface. On success,returns0, setsbuffer to the memory location andbuffer_len to thebuffer length. Returns-1 and sets aTypeError on error.