[pypy-commit] pypy default: make sure that shape is nonresizable
fijal
noreply at buildbot.pypy.org
Sun Oct 28 00:33:29 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r58526:184ad638e30d
Date: 2012-10-28 00:31 +0200
http://bitbucket.org/pypy/pypy/changeset/184ad638e30d/
Log: make sure that shape is nonresizable
diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -10,6 +10,7 @@
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rlib import jit
from pypy.rlib.rawstorage import free_raw_storage
+from pypy.rlib.debug import make_sure_not_resized
class ConcreteArrayIterator(base.BaseArrayIterator):
def __init__(self, array):
@@ -379,6 +380,7 @@
class ConcreteArray(BaseConcreteArray):
def __init__(self, shape, dtype, order, strides, backstrides):
+ make_sure_not_resized(shape)
self.shape = shape
self.size = support.product(shape) * dtype.get_size()
self.storage = dtype.itemtype.malloc(self.size)
diff --git a/pypy/module/micronumpy/dot.py b/pypy/module/micronumpy/dot.py
--- a/pypy/module/micronumpy/dot.py
+++ b/pypy/module/micronumpy/dot.py
@@ -11,12 +11,12 @@
right_critical_dim = len(right_shape) - 2
right_critical_dim_size = right_shape[right_critical_dim]
assert right_critical_dim >= 0
- out_shape += left_shape[:-1] + \
- right_shape[0:right_critical_dim] + \
- right_shape[right_critical_dim + 1:]
+ out_shape = out_shape + left_shape[:-1] + \
+ right_shape[0:right_critical_dim] + \
+ right_shape[right_critical_dim + 1:]
elif len(right_shape) > 0:
#dot does not reduce for scalars
- out_shape += left_shape[:-1]
+ out_shape = out_shape + left_shape[:-1]
if my_critical_dim_size != right_critical_dim_size:
raise OperationError(space.w_ValueError, space.wrap(
"objects are not aligned"))
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
@@ -25,7 +25,7 @@
shape = []
for w_item in space.fixedview(w_size):
shape.append(space.int_w(w_item))
- return shape
+ return shape[:]
class __extend__(W_NDimArray):
@jit.unroll_safe
diff --git a/pypy/module/micronumpy/strides.py b/pypy/module/micronumpy/strides.py
--- a/pypy/module/micronumpy/strides.py
+++ b/pypy/module/micronumpy/strides.py
@@ -64,13 +64,13 @@
while True:
new_batch = []
if not batch:
- return shape, []
+ return shape[:], []
if is_single_elem(space, batch[0], is_rec_type):
for w_elem in batch:
if not is_single_elem(space, w_elem, is_rec_type):
raise OperationError(space.w_ValueError, space.wrap(
"setting an array element with a sequence"))
- return shape, batch
+ return shape[:], batch
size = space.len_w(batch[0])
for w_elem in batch:
if (is_single_elem(space, w_elem, is_rec_type) or
More information about the pypy-commit
mailing list