1. Pypy
  2. Untitled project
  3. pypy

Commits

Matti Picus  committed c1a7865

fix test, change implementation for pendatic exception string, improve test

  • Participants
  • Parent commits 21c62d1
  • Branches pypy-pyarray

Comments (0)

Files changed (3)

File pypy/module/cpyext/ndarrayobject.py

View file
  • Ignore whitespace
 
 @cpython_api([PyObject, Py_ssize_t, Py_ssize_t, Py_ssize_t], PyObject)
 def _PyArray_FromObject(space, w_obj, typenum, min_depth, max_depth):
-    return _PyArray_FromAny(space, w_obj, typenum, min_depth, max_depth, NPY_BEHAVED);
-
+    try:
+        return _PyArray_FromAny(space, w_obj, typenum, min_depth, max_depth,
+                            0, None);
+    except OperationError, e:
+        if e.match(space, space.w_NotImplementedError):
+            errstr = space.str_w(e.get_w_value(space))
+            errstr = errstr.replace('FromAny','FromObject')
+            raise OperationError(space.w_NotImplementedError, space.wrap(
+                errstr))
+        raise
 
 def get_shape_and_dtype(space, nd, dims, typenum):
     shape = []

File pypy/module/cpyext/test/test_api.py

View file
  • Ignore whitespace
             raise Exception("DID NOT RAISE")
         if getattr(space, 'w_' + expected_exc.__name__) is not operror.w_type:
             raise Exception("Wrong exception")
-        state.clear_exception()
+        return state.clear_exception()
 
     def setup_method(self, func):
         freeze_refcnts(self)

File pypy/module/cpyext/test/test_ndarrayobject.py

View file
  • Ignore whitespace
 
     def test_FromObject(self, space, api):
         a = array(space, [10, 5, 3])
-        assert api._PyArray_FromObject(a, NULL, 0, 0, 0, NULL) is a
-        self.raises(space, api, NotImplementedError, api._PyArray_FromObject,
-                    space.wrap(a), space.w_None, space.wrap(0),
-                    space.wrap(3), space.wrap(0), space.w_None)
+        assert api._PyArray_FromObject(a, None, 0, 0) is a
+        exc = self.raises(space, api, NotImplementedError, api._PyArray_FromObject,
+                    space.wrap(a), space.wrap(11), space.wrap(0),
+                    space.wrap(3) )
+        assert exc.errorstr(space).find('FromObject') >= 0
 
     def test_list_from_fixedptr(self, space, api):
         A = lltype.GcArray(lltype.Float)