[pypy-commit] pypy object-dtype: Now that object arrays work, raise the proper exception

rguillebert noreply at buildbot.pypy.org
Wed Jan 28 16:57:40 CET 2015


Author: Romain Guillebert <romain.py at gmail.com>
Branch: object-dtype
Changeset: r75565:7f1fc67f7b45
Date: 2015-01-28 16:55 +0100
http://bitbucket.org/pypy/pypy/changeset/7f1fc67f7b45/

Log:	Now that object arrays work, raise the proper exception

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
@@ -157,6 +157,8 @@
             if (isinstance(w_item, W_NDimArray) or
                     space.isinstance_w(w_item, space.w_list)):
                 w_item = convert_to_array(space, w_item)
+                if w_item.implementation.dtype.num == NPY.OBJECT:
+                    raise OperationError(space.w_TypeError, space.wrap("long() argument must be a string or a number, not 'object'")) # Mimic numpy's error message
                 if shape is None:
                     shape = w_item.get_shape()
                 else:
diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3135,11 +3135,7 @@
         assert b[35] == 200
         b[[slice(25, 30)]] = range(5)
         assert all(a[:5] == range(5))
-        import sys
-        if '__pypy__' not in sys.builtin_module_names:
-            raises(TypeError, 'b[[[slice(25, 125)]]]')
-        else:
-            raises(NotImplementedError, 'b[[[slice(25, 125)]]]')
+        raises(TypeError, 'b[[[slice(25, 125)]]]')
 
     def test_cumsum(self):
         from numpy import arange


More information about the pypy-commit mailing list