Message139758
Pauli Virtanen <report@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. |
|
Date |
User |
Action |
Args |
2011-07-04 12:21:10 | skrah | set | recipients:
+ skrah, teoliphant, mark.dickinson, ncoghlan, rupole, kermode, pitrou, vstinner, pv, jcon, petri.lehtinen |
2011-07-04 12:21:09 | skrah | link | issue10181 messages |
2011-07-04 12:21:09 | skrah | create | |
|