[Python-3000] bug in py3k buffer object?
Travis Oliphant
oliphant.travis at ieee.org
Wed Sep 5 22:45:55 CEST 2007
Lisandro Dalcin wrote:
> Dear Travis, in my MPI wrappers, I use MPI_Alloc_mem function to get
> 'special' MPI memory, and next I return it to Python using
>
> return PyBuffer_FromReadWriteMemory(ptr, len);
>
> Well, getting back this rw-buffer in python, I tried to do
>
> mem = MPI.Alloc_mem(10)
> mem[:] = str8('\0') * 8 # sort of memzero
>
> but then I get this error:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: buffer is read-only
>
>
> I noticed you use PyBuff_SIMPLE in
> buffer_ass_item/buffer_ass_subscript... Is this OK? perhaps
> PyBuf_WRITEABLE is the right flag? No much more time to go deeper.
>
yes, I see the problem. The problem is with get_buf not setting
view->readonly when it the buffer object has a NULL base (i.e. its own
memory).
I'll fix this and check it in as soon as I get on a machine with
check-in possibilities.
-Travis
More information about the Python-3000
mailing list