Re: [Numpy-discussion] Deserialized arrays with base mutate strings

2009-09-23 Thread Robert Kern
On Wed, Sep 23, 2009 at 13:59, Pauli Virtanen wrote: > ke, 2009-09-23 kello 10:01 +0200, Hrvoje Niksic kirjoitti: > [clip] >> I guess this one could be prevented by verifying that the buffer is >> writable when setting the "writable" flag.  When deserializing arrays, I >> don't see a reason for th

Re: [Numpy-discussion] Deserialized arrays with base mutate strings

2009-09-23 Thread Pauli Virtanen
ke, 2009-09-23 kello 10:01 +0200, Hrvoje Niksic kirjoitti: [clip] > I guess this one could be prevented by verifying that the buffer is > writable when setting the "writable" flag. When deserializing arrays, I > don't see a reason for the "base" property to even exist - sharing of > the buffer

Re: [Numpy-discussion] Deserialized arrays with base mutate strings

2009-09-23 Thread Hrvoje Niksic
Pauli Virtanen wrote: > Wed, 23 Sep 2009 09:15:44 +0200, Hrvoje Niksic wrote: > [clip] >> Numpy arrays with the "base" property are deserialized as arrays >> pointing to a storage contained within a Python string. This is a >> problem since such arrays are mutable and can mutate existing strings.

Re: [Numpy-discussion] Deserialized arrays with base mutate strings

2009-09-23 Thread Pauli Virtanen
Wed, 23 Sep 2009 09:15:44 +0200, Hrvoje Niksic wrote: [clip] > Numpy arrays with the "base" property are deserialized as arrays > pointing to a storage contained within a Python string. This is a > problem since such arrays are mutable and can mutate existing strings. > Here is how to create one:

[Numpy-discussion] Deserialized arrays with base mutate strings

2009-09-23 Thread Hrvoje Niksic
Numpy arrays with the "base" property are deserialized as arrays pointing to a storage contained within a Python string. This is a problem since such arrays are mutable and can mutate existing strings. Here is how to create one: >>> import numpy, cPickle as p >>> a = numpy.array([1, 2, 3])