This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients jcon, kermode, mark.dickinson, ncoghlan, petri.lehtinen, pitrou, pv, rupole, skrah, teoliphant, vstinner
Date 2011-07-04.12:21:09
SpamBayes Score 3.9253653e-08
Marked as misclassified No
Message-id <20110704121902.GA14216@sleipnir.bytereef.org>
In-reply-to <1309777147.03.0.276482872267.issue10181@psf.upfronthosting.co.za>
Content
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.
History
Date User Action Args
2011-07-04 12:21:10skrahsetrecipients: + skrah, teoliphant, mark.dickinson, ncoghlan, rupole, kermode, pitrou, vstinner, pv, jcon, petri.lehtinen
2011-07-04 12:21:09skrahlinkissue10181 messages
2011-07-04 12:21:09skrahcreate