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


Groups > comp.lang.python > #63690 > unrolled thread

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

Started byMark Heieis <mheieis@alois.ca>
First post2014-01-10 21:47 -0800
Last post2014-01-10 21:47 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

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

FromMark Heieis <mheieis@alois.ca>
Date2014-01-10 21:47 -0800
SubjectPorting c extension - PyBuffer_New() deprecated in python3. What's the replacement?
Message-ID<mailman.5320.1389429147.18130.python-list@python.org>
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.



[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web