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

arigo at codespeak.net arigo at codespeak.net
Wed Dec 6 03:02:55 CET 2006


Author: arigo
Date: Wed Dec  6 03:02:32 2006
New Revision: 35353

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/rpython/test/test_rpbc.py
Log:
(pedronis, arigo)

Yet another rpbc corner case.


Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Wed Dec  6 03:02:32 2006
@@ -630,11 +630,23 @@
         return SomeBuiltin(bltn1.analyser, s_self, methodname=bltn1.methodname)
 
 class __extend__(pairtype(SomePBC, SomePBC)):
+
     def union((pbc1, pbc2)):       
         d = pbc1.descriptions.copy()
         d.update(pbc2.descriptions)
         return SomePBC(d, can_be_None = pbc1.can_be_None or pbc2.can_be_None)
 
+    def is_((obj1, obj2)):
+        thistype = pairtype(SomePBC, SomePBC)
+        s = super(thistype, pair(obj1, obj2)).is_()
+        if not s.is_constant():
+            for desc in obj1.descriptions:
+                if desc in obj2.descriptions:
+                    break
+            else:
+                s.const = False    # no common desc in the two sets
+        return s
+
 class __extend__(pairtype(SomeImpossibleValue, SomeObject)):
     def union((imp1, obj2)):
         return obj2

Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py	Wed Dec  6 03:02:32 2006
@@ -1477,6 +1477,20 @@
         res = self.interpret(f, [5])
         assert res == 123
 
+    def test_is_among_functions(self):
+        def g1(): pass
+        def g2(): pass
+        def g3(): pass
+        def f(n):
+            if n > 5:
+                g = g2
+            else:
+                g = g1
+            g()
+            g3()
+            return g is g3
+        res = self.interpret(f, [2])
+        assert res == False
 
 # We don't care about the following test_hlinvoke tests working on
 # ootype. Maybe later. This kind of thing is only used in rdict



More information about the Pypy-commit mailing list