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

fijal at codespeak.net fijal at codespeak.net
Fri Jun 27 22:44:11 CEST 2008


Author: fijal
Date: Fri Jun 27 22:44:09 2008
New Revision: 56143

Modified:
   pypy/dist/pypy/objspace/descroperation.py
   pypy/dist/pypy/objspace/test/test_descroperation.py
Log:
A test and a fix


Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Fri Jun 27 22:44:09 2008
@@ -501,8 +501,8 @@
             w_right_impl = None
         else:
             w_right_src, w_right_impl = space.lookup_in_type_where(w_typ2, right)
-            if (w_left_src is not w_right_src    # XXX see binop_impl
-                and space.is_true(space.issubtype(w_typ2, w_typ1))):
+            # XXX see binop_impl
+            if space.is_true(space.issubtype(w_typ2, w_typ1)):
                 w_obj1, w_obj2 = w_obj2, w_obj1
                 w_left_impl, w_right_impl = w_right_impl, w_left_impl
 

Modified: pypy/dist/pypy/objspace/test/test_descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_descroperation.py	(original)
+++ pypy/dist/pypy/objspace/test/test_descroperation.py	Fri Jun 27 22:44:09 2008
@@ -328,6 +328,25 @@
 
         setattr(P, "__weakref__", 0)
 
+    def test_subclass_comparison(self):
+        l = []
+        class A(object):
+            def __eq__(self, other):
+                l.append(self.__class__)
+                l.append(other.__class__)
+                return False
+
+            def __lt__(self, other):
+                l.append(self.__class__)
+                l.append(other.__class__)
+                return False
+
+        class B(A):
+            pass
+
+        A() == B()
+        A() < B()
+        assert l == [B, A, A, B]
 
 class AppTestWithBuiltinShortcut(AppTest_Descroperation):
     OPTIONS = {'objspace.std.builtinshortcut': True}



More information about the Pypy-commit mailing list