Porting c extension - PyBuffer_New() deprecated in python3. What'sthe replacement?

M

Mark Heieis

Hi

I need to convert the following existing c extension code to support
Python 3.

// --- existing code ------

// PyBuffer_New() deprecated in python3
if (!(pyBuf = PyBuffer_New(len)))
{
return NULL;
}

// should use memoryview object in python3
if (PyObject_AsWriteBuffer(pyBuf, &cbuf, &len))
{
Py_DECREF(pyBuf);
return NULL ;
}

// fill in cbuf
...

return pyBuf ;

//-----------

I'm somewhat confounded in finding an equivalent (PyBuffer_New()) for
creating a buffer of size len that has continuous memory in the c
extension function for python3. cbuf is manipulated/filled in using c,
after which the created pyBuf is then returned. So far, I haven't found
much in the way of examples/doc for porting the deprecated
Python-/C-level buffer API calls to the new C-level buffer
API/memoryview object model.

Any guidance or direction to existing doc/example is much appreciated.

TIA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top