Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r58246:dd6debeadbe9
Date: 2012-10-19 17:13 +0200
http://bitbucket.org/pypy/pypy/changeset/dd6debeadbe9/

Log:    revert 8617a5ed3187 and fix it by actually returning NotImplemented
        from complex.__lt__&co. Not sure this is the 100% right way to do
        it, but it seems to do the job

diff --git a/lib-python/3.2/test/test_complex.py 
b/lib-python/3.2/test/test_complex.py
--- a/lib-python/3.2/test/test_complex.py
+++ b/lib-python/3.2/test/test_complex.py
@@ -123,11 +123,10 @@
             self.assertIs(complex.__ne__(f+0j, f), False)
             self.assertIs(complex.__eq__(complex(f, f), f), False)
             self.assertIs(complex.__ne__(complex(f, f), f), True)
-        if support.check_impl_detail(pypy=False):
-            self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
-            self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
-            self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
-            self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented)
+        self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
+        self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
+        self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
+        self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented)
         self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j)
         self.assertRaises(TypeError, operator.le, 1+1j, 2+2j)
         self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j)
diff --git a/pypy/objspace/std/complexobject.py 
b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -201,7 +201,8 @@
     return ne__Complex_Long(space, w_complex2, w_long1)
 
 def lt__Complex_Complex(space, w_complex1, w_complex2):
-    raise OperationError(space.w_TypeError, space.wrap('cannot compare complex 
numbers using <, <=, >, >='))
+    from pypy.objspace.std.model import FailedToImplement
+    raise FailedToImplement
 
 gt__Complex_Complex = lt__Complex_Complex
 ge__Complex_Complex = lt__Complex_Complex
diff --git a/pypy/objspace/std/test/test_complexobject.py 
b/pypy/objspace/std/test/test_complexobject.py
--- a/pypy/objspace/std/test/test_complexobject.py
+++ b/pypy/objspace/std/test/test_complexobject.py
@@ -169,15 +169,20 @@
         raises(TypeError, "3+0j // 0+0j")
 
     def test_richcompare(self):
+        import operator
         assert complex.__lt__(1+1j, None) is NotImplemented
         assert complex.__eq__(1+1j, 2+2j) is False
         assert complex.__eq__(1+1j, 1+1j) is True
         assert complex.__ne__(1+1j, 1+1j) is False
         assert complex.__ne__(1+1j, 2+2j) is True
-        raises(TypeError, complex.__lt__, 1+1j, 2+2j)
-        raises(TypeError, complex.__le__, 1+1j, 2+2j)
-        raises(TypeError, complex.__gt__, 1+1j, 2+2j)
-        raises(TypeError, complex.__ge__, 1+1j, 2+2j)
+        assert complex.__lt__(1+1j, 2+2j) is NotImplemented
+        assert complex.__le__(1+1j, 2+2j) is NotImplemented
+        assert complex.__gt__(1+1j, 2+2j) is NotImplemented
+        assert complex.__ge__(1+1j, 2+2j) is NotImplemented
+        raises(TypeError, operator.lt, 1+1j, 2+2j)
+        raises(TypeError, operator.le, 1+1j, 2+2j)
+        raises(TypeError, operator.gt, 1+1j, 2+2j)
+        raises(TypeError, operator.ge, 1+1j, 2+2j)
         large = 1 << 10000
         assert not (5+0j) == large
         assert not large == (5+0j)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to