Commits

mattip committed c1a7865

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

Comments (0)

Files changed (3)

pypy/module/cpyext/ndarrayobject.py

 
 @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 = []

pypy/module/cpyext/test/test_api.py

             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)

pypy/module/cpyext/test/test_ndarrayobject.py

 
     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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.