]> granicus.if.org Git - python/commitdiff
Oops! 2.6's Rational.__ne__ didn't work.
authorJeffrey Yasskin <jyasskin@gmail.com>
Fri, 8 Feb 2008 06:45:40 +0000 (06:45 +0000)
committerJeffrey Yasskin <jyasskin@gmail.com>
Fri, 8 Feb 2008 06:45:40 +0000 (06:45 +0000)
Lib/numbers.py
Lib/test/test_rational.py

index e391abc387ad33c14203bbcc9ccd2e647492e698..cbcecedeca1c404c55a6eae8d99507a17afcd739 100644 (file)
@@ -174,7 +174,10 @@ class Complex(Number):
         """self == other"""
         raise NotImplementedError
 
-    # __ne__ is inherited from object and negates whatever __eq__ does.
+    def __ne__(self, other):
+        """self != other"""
+        # The default __ne__ doesn't negate __eq__ until 3.0.
+        return not (self == other)
 
 Complex.register(complex)
 
index 5679c5a1b2d404f2a8b5a35b9f7bc5580d9d5762..8e620813a99be1365fd4600fba0b791327fbc7a1 100644 (file)
@@ -313,6 +313,8 @@ class RationalTest(unittest.TestCase):
         self.assertFalse(R(2, 3) <= R(1, 2))
         self.assertTrue(R(1, 2) == R(1, 2))
         self.assertFalse(R(1, 2) == R(1, 3))
+        self.assertFalse(R(1, 2) != R(1, 2))
+        self.assertTrue(R(1, 2) != R(1, 3))
 
     def testMixedLess(self):
         self.assertTrue(2 < R(5, 2))