[pypy-svn] r54529 - in pypy/dist/pypy/objspace/std: . test

arigo at codespeak.net arigo at codespeak.net
Wed May 7 14:48:12 CEST 2008


Author: arigo
Date: Wed May  7 14:48:10 2008
New Revision: 54529

Modified:
   pypy/dist/pypy/objspace/std/objspace.py
   pypy/dist/pypy/objspace/std/test/test_longobject.py
Log:
Revert r50884.  Sorry fijal, I couldn't understand its purpose
and it breaks allworkingmodules on 64-bit machines
(as shown by a new test).


Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py	(original)
+++ pypy/dist/pypy/objspace/std/objspace.py	Wed May  7 14:48:10 2008
@@ -15,8 +15,7 @@
 from pypy.objspace.std.multimethod import FailedToImplement
 from pypy.objspace.descroperation import DescrOperation
 from pypy.objspace.std import stdtypedef
-from pypy.rlib.rarithmetic import base_int, r_int, r_uint, \
-     r_longlong, r_ulonglong
+from pypy.rlib.rarithmetic import base_int
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.jit import hint, we_are_jitted
 from pypy.rlib.unroll import unrolling_iterable
@@ -477,8 +476,7 @@
             w_result = x.__spacebind__(self)
             #print 'wrapping', x, '->', w_result
             return w_result
-        if isinstance(x, r_int) or isinstance(x, r_uint) or \
-           isinstance(x, r_longlong) or isinstance(x, r_ulonglong):
+        if isinstance(x, base_int):
             return W_LongObject.fromrarith_int(x)
 
         # _____ below here is where the annotator should not get _____
@@ -500,7 +498,7 @@
 
         # The following cases are even stranger.
         # Really really only for tests.
-        if isinstance(x, long):
+        if type(x) is long:
             return W_LongObject.fromlong(x)
         if isinstance(x, slice):
             return W_SliceObject(self.wrap(x.start),

Modified: pypy/dist/pypy/objspace/std/test/test_longobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_longobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_longobject.py	Wed May  7 14:48:10 2008
@@ -5,9 +5,13 @@
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import r_uint
 from pypy.rlib.rbigint import rbigint
+from pypy.conftest import gettestobjspace
 
 class TestW_LongObject:
 
+    def setup_class(cls):
+        cls.space = gettestobjspace(**{"objspace.nofaking": True})
+
     def test_bigint_w(self):
         space = self.space
         fromlong = lobj.W_LongObject.fromlong
@@ -19,6 +23,21 @@
         w_obj = space.wrap(123.456)
         space.raises_w(space.w_TypeError, space.bigint_w, w_obj)
 
+    def test_rint_variants(self):
+        from pypy.rpython.tool.rfficache import platform
+        space = self.space
+        for r in platform.numbertype_to_rclass.values():
+            if r is int:
+                continue
+            print r
+            values = [0, -1, r.MASK>>1, -(r.MASK>>1)-1]
+            for x in values:
+                if not r.SIGNED:
+                    x &= r.MASK
+                w_obj = space.wrap(r(x))
+                assert space.bigint_w(w_obj).eq(rbigint.fromint(x))
+
+
 class AppTestLong:
     def test_add(self):
         assert int(123L + 12443L) == 123 + 12443



More information about the Pypy-commit mailing list