[pypy-svn] r20888 - in pypy/dist/pypy: annotation rpython/test

mwh at codespeak.net mwh at codespeak.net
Thu Dec 8 13:20:38 CET 2005


Author: mwh
Date: Thu Dec  8 13:20:36 2005
New Revision: 20888

Modified:
   pypy/dist/pypy/annotation/builtin.py
   pypy/dist/pypy/rpython/test/test_rint.py
Log:
(mwh, johahn)

fix up builtin_isinstance wrt the changes to how integers
are annotated.


Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py	(original)
+++ pypy/dist/pypy/annotation/builtin.py	Thu Dec  8 13:20:36 2005
@@ -112,12 +112,11 @@
     r = SomeBool() 
     if s_type.is_constant():
         typ = s_type.const
-        if typ == pypy.rpython.rarithmetic.r_uint:
+        if issubclass(typ, pypy.rpython.rarithmetic.base_int):
             if s_obj.is_constant():
                 r.const = isinstance(s_obj.const, typ)
             else:
-                if s_obj.knowntype == int:
-                    r.const = s_obj.unsigned
+                r.const = issubclass(s_obj.knowntype, typ)
         else:
             if typ == long:
                 getbookkeeper().warning("isinstance(., long) is not RPython")

Modified: pypy/dist/pypy/rpython/test/test_rint.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rint.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rint.py	Thu Dec  8 13:20:36 2005
@@ -121,3 +121,21 @@
         return int(i)
     res = interpret(f, [r_longlong(0)])
     assert res == 0
+
+def test_isinstance_vs_int_types():
+    class FakeSpace(object):
+        def wrap(self, x):
+            if x is None:
+                return [None]
+            if isinstance(x, str):
+                return x
+            if isinstance(x, r_longlong):
+                return int(x)
+            return "XXX"
+        wrap._annspecialcase_ = 'specialize:argtype0'
+
+    space = FakeSpace()
+    def wrap(x):
+        return space.wrap(x)
+    res = interpret(wrap, [r_longlong(0)])
+    assert res == 0



More information about the Pypy-commit mailing list