Author: Matti Picus <[email protected]>
Branch: numpypy-segfault
Changeset: r65154:863f80543401
Date: 2013-07-01 17:44 +0300
http://bitbucket.org/pypy/pypy/changeset/863f80543401/
Log: do not iter over empty arrays
diff --git a/pypy/module/micronumpy/interp_arrayops.py
b/pypy/module/micronumpy/interp_arrayops.py
--- a/pypy/module/micronumpy/interp_arrayops.py
+++ b/pypy/module/micronumpy/interp_arrayops.py
@@ -65,7 +65,7 @@
[ 3., 4., -1.],
[-1., -1., -1.]])
-
+
NOTE: support for not passing x and y is unsupported
"""
if space.is_none(w_y):
@@ -122,10 +122,10 @@
for f in dtype.fields:
if f not in a_dt.fields or \
dtype.fields[f] != a_dt.fields[f]:
- raise OperationError(space.w_TypeError,
+ raise OperationError(space.w_TypeError,
space.wrap("record type mismatch"))
elif dtype.is_record_type() or a_dt.is_record_type():
- raise OperationError(space.w_TypeError,
+ raise OperationError(space.w_TypeError,
space.wrap("invalid type promotion"))
dtype = interp_ufuncs.find_binop_result_dtype(space, dtype,
arr.get_dtype())
diff --git a/pypy/module/micronumpy/iter.py b/pypy/module/micronumpy/iter.py
--- a/pypy/module/micronumpy/iter.py
+++ b/pypy/module/micronumpy/iter.py
@@ -46,6 +46,7 @@
calculate_slice_strides
from pypy.module.micronumpy.base import W_NDimArray
from pypy.module.micronumpy.arrayimpl import base
+from pypy.module.micronumpy.support import product
from rpython.rlib import jit
# structures to describe slicing
@@ -225,7 +226,7 @@
self.shape = shape
self.offset = start
self.shapelen = len(shape)
- self._done = False
+ self._done = self.shapelen == 0 or product(shape) == 0
self.strides = strides
self.backstrides = backstrides
self.size = array.size
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit