Author: Maciej Fijalkowski <fij...@gmail.com> Branch: Changeset: r50250:a23933bd7963 Date: 2011-12-07 16:57 +0200 http://bitbucket.org/pypy/pypy/changeset/a23933bd7963/
Log: fixes diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -918,7 +918,8 @@ def descr_array_iface(self, space): concrete = self.get_concrete() - addr = rffi.cast(lltype.Signed, concrete.storage) + storage = concrete.get_storage(space) + addr = rffi.cast(lltype.Signed, storage) w_d = space.newdict() space.setitem_str(w_d, 'data', space.newtuple([space.wrap(addr), space.w_False])) @@ -984,6 +985,9 @@ # so in order to have a consistent API, let it go through. pass + def get_storage(self, space): + raise OperationError(space.w_TypeError, space.wrap("Cannot get array interface on scalars in pypy")) + class VirtualArray(BaseArray): """ Class for representing virtual arrays, such as binary ops or ufuncs @@ -1271,6 +1275,9 @@ a_iter = a_iter.next(len(array.shape)) return array + def get_storage(self, space): + return self.parent.storage + class W_NDimArray(BaseArray): """ A class representing contiguous array. We know that each iteration by say ufunc will increase the data index by one @@ -1333,6 +1340,9 @@ def debug_repr(self): return 'Array' + def get_storage(self, space): + return self.storage + def __del__(self): lltype.free(self.storage, flavor='raw', track_allocation=False) diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -1119,6 +1119,10 @@ a = array([1, 2, 3]) i = a.__array_interface__ assert isinstance(i['data'][0], int) + a = a[::2] + i = a.__array_interface__ + assert isinstance(i['data'][0], int) + raises(TypeError, getattr, array(3), '__array_interface__') class AppTestSupport(BaseNumpyAppTest): def setup_class(cls): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit