[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)
Stefan Krah
report at bugs.python.org
Mon Jul 4 14:21:09 CEST 2011
Stefan Krah <stefan-usenet at bytereef.org> added the comment:
Pauli Virtanen <report at bugs.python.org> wrote:
> Comment on the patch: it seems you do not track the re-export count in memory_getbuf:
>
> a = memoryview(obj)
> b = numpy.asarray(a)
> a.release()
> b[0] = 123 # <-- BOOM: the buffer was already released
Could you give the exact sequence of events (including the creation of obj)?
For me this works:
Python 3.3a0 (memoryview:bbe70ca4e0e5+, Jul 4 2011, 13:55:55)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> obj = bytearray(b'123456789')
>>> a = memoryview(obj)
>>> b = numpy.asarray(a)
>>> a.release()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BufferError: several memoryviews are active
>>> b[0] = 123
>>> b
array([123, 50, 51, 52, 53, 54, 55, 56, 57], dtype=uint8)
>>> del a
>>> b[0] = 224
>>> b
array([224, 50, 51, 52, 53, 54, 55, 56, 57], dtype=uint8)
> (I had some code for n-dim slicing etc. in my first patch that could be
> useful to have too; I'll see if I find time to dig them out here.)
That would be nice.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10181>
_______________________________________
More information about the Python-bugs-list
mailing list