Author: mattip <[email protected]>
Branch:
Changeset: r80822:fce4c7d4a8b9
Date: 2015-11-22 00:02 +0200
http://bitbucket.org/pypy/pypy/changeset/fce4c7d4a8b9/
Log: test, fix for disallowing record array with mixed object, non-object
values
until we figure out a way to mark the gc pointers in the raw storage
diff --git a/pypy/module/micronumpy/ndarray.py
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -15,7 +15,7 @@
from pypy.module.micronumpy.arrayops import repeat, choose, put
from pypy.module.micronumpy.base import W_NDimArray, convert_to_array, \
ArrayArgumentException, wrap_impl
-from pypy.module.micronumpy.concrete import BaseConcreteArray
+from pypy.module.micronumpy.concrete import BaseConcreteArray, V_OBJECTSTORE
from pypy.module.micronumpy.converters import (
multi_axis_converter, order_converter, shape_converter,
searchside_converter, out_converter)
@@ -288,6 +288,9 @@
raise oefmt(space.w_ValueError, "no field of name %s", field)
arr = self.implementation
ofs, subdtype = arr.dtype.fields[field][:2]
+ if subdtype.is_object() and arr.gcstruct is V_OBJECTSTORE:
+ raise oefmt(space.w_NotImplementedError,
+ "cannot read object from array with no gc hook")
# ofs only changes start
# create a view of the original array by extending
# the shape, strides, backstrides of the array
diff --git a/pypy/module/micronumpy/test/test_object_arrays.py
b/pypy/module/micronumpy/test/test_object_arrays.py
--- a/pypy/module/micronumpy/test/test_object_arrays.py
+++ b/pypy/module/micronumpy/test/test_object_arrays.py
@@ -126,8 +126,6 @@
interface = dict(a.__array_interface__)
interface['shape'] = tuple([3])
interface['strides'] = tuple([0])
- if '__pypy__' in sys.builtin_module_names:
- skip('not implemented yet')
c = np.array(DummyArray(interface, base=a))
c.dtype = a.dtype
#print c
@@ -160,6 +158,9 @@
import sys
ytype = np.object_
if '__pypy__' in sys.builtin_module_names:
+ dt = np.dtype([('x', int), ('y', ytype)])
+ x = np.empty((4, 0), dtype = dt)
+ raises(NotImplementedError, x.__getitem__, 'y')
ytype = str
dt = np.dtype([('x', int), ('y', ytype)])
# Correct way
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1851,6 +1851,9 @@
arr.gcstruct)
def read(self, arr, i, offset, dtype):
+ if arr.gcstruct is V_OBJECTSTORE:
+ raise oefmt(self.space.w_NotImplementedError,
+ "cannot read object from array with no gc hook")
return self.box(self._read(arr.storage, i, offset))
def byteswap(self, w_v):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit