From: Jeffrey Yasskin Date: Fri, 8 Feb 2008 06:45:40 +0000 (+0000) Subject: Oops! 2.6's Rational.__ne__ didn't work. X-Git-Tag: v2.6a1~230 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27d339446af6fbd636c58090c5c7e15ec4551dd9;p=python Oops! 2.6's Rational.__ne__ didn't work. --- diff --git a/Lib/numbers.py b/Lib/numbers.py index e391abc387..cbcecedeca 100644 --- a/Lib/numbers.py +++ b/Lib/numbers.py @@ -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) diff --git a/Lib/test/test_rational.py b/Lib/test/test_rational.py index 5679c5a1b2..8e620813a9 100644 --- a/Lib/test/test_rational.py +++ b/Lib/test/test_rational.py @@ -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))