[pypy-commit] pypy default: test, fix int64 < 0 conversion on 32 bit platforms

mattip noreply at buildbot.pypy.org
Thu Dec 25 22:00:58 CET 2014


Author: mattip <matti.picus at gmail.com>
Branch: 
Changeset: r75124:0a4307698d88
Date: 2014-12-25 22:58 +0200
http://bitbucket.org/pypy/pypy/changeset/0a4307698d88/

Log:	test, fix int64 < 0 conversion on 32 bit platforms

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
@@ -287,6 +287,8 @@
         a = np.array('123', dtype='intp')
         assert a == 123
         assert a.dtype == np.intp
+        a = np.array( -(2**60))
+        assert a.dtype == np.int64
 
     def test_array_copy(self):
         from numpy import array
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -619,6 +619,9 @@
             space.int_w(w_obj)
         except OperationError, e:
             if e.match(space, space.w_OverflowError):
+                if space.r_longlong_w(w_obj) < 0:
+                    return find_binop_result_dtype(space, int64_dtype,
+                                               current_guess)
                 return find_binop_result_dtype(space, uint64_dtype,
                                                current_guess)
             raise


More information about the pypy-commit mailing list