Antonio Cuni  committed 2d36719

fix Issue1389 and Issue1281: we need to interpret the dtype before doing the comparison with the existing one

  • Participants
  • Parent commits bed8589
  • Branches default

Comments (0)

Files changed (2)

File pypy/module/micronumpy/

         if order != 'C':  # or order != 'F':
             raise operationerrfmt(space.w_ValueError, "Unknown order: %s",
+    dtype = interp_dtype.decode_w_dtype(space, w_dtype)
     if isinstance(w_object, W_NDimArray):
         if (not space.is_none(w_dtype) and
-            w_object.get_dtype() is not w_dtype):
+            w_object.get_dtype() is not dtype):
             raise OperationError(space.w_NotImplementedError, space.wrap(
                                   "copying over different dtypes unsupported"))
         if copy:
             return w_object.descr_copy(space)
         return w_object
-    dtype = interp_dtype.decode_w_dtype(space, w_dtype)
     shape, elems_w = find_shape_and_elems(space, w_object, dtype)
     if dtype is None:
         for w_elem in elems_w:

File pypy/module/micronumpy/test/

         assert a[1] == 0xff
         assert len( == 16
+    def test_explicit_dtype_conversion(self):
+        from _numpypy import array
+        a = array([1.0, 2.0])
+        b = array(a, dtype='d')
+        assert a.dtype is b.dtype
 class AppTestMultiDim(BaseNumpyAppTest):
     def test_init(self):
         import _numpypy