docs error for PyBuffer_FillInfo?

D

Diez B. Roggisch

I'm trying to wrap a C++-lib with SIP & need to return a buffer-object
from one method.

I'm on python2.6 (OS X, but that doesn't matter I guess), and

http://docs.python.org/c-api/buffer.html#Py_buffer

gives a signature like this:

int PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len, int
readonly, int infoflags)¶

However, the abstract.h of the Python-installation has this:

PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o,
void *buf,
Py_ssize_t len, int readonly,
int flags);



And obviously enough, compiling my wrapper fails because there is an
argument missing.

So, I'm in need for a guide on how to use PyBuffer_FillInfo properly -
all I've got is a void* and a total size of the buffer.

Diez
 
D

Diez B. Roggisch

Christian said:
The second argument points to the (optional) object for that you are
creating the view. The code in Object/stringobject.c is a good example:

static int
string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags)
{
return PyBuffer_FillInfo(view, (PyObject*)self,
(void *)self->ob_sval, Py_SIZE(self),
1, flags);
}

But doesn't this mean the docs are faulty? Shall I report a bug?

And I have to say that the docs are anything but clear to me. As I said,
I've got a method

void *lock(readonly=True)

as part of a C++-library. So, all I've got is a void-pointer and a
length (through another method).

But I'm unsure about how to allocate the view - just with malloc? What
about reference-counting, do I have to increment it?

A self-contained example in the docs would be great. Any pointers?

Thanks,

Diez
 

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,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top