Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63690

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

Date 2014-01-10 21:47 -0800
From Mark Heieis <mheieis@alois.ca>
Subject Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement?
Newsgroups comp.lang.python
Message-ID <mailman.5320.1389429147.18130.python-list@python.org> (permalink)

Show all headers | View raw


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.



Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement? Mark Heieis <mheieis@alois.ca> - 2014-01-10 21:47 -0800

csiph-web