[Python-checkins] r60667 - in python/trunk/Lib: numbers.py test/test_rational.py

jeffrey.yasskin python-checkins at python.org
Fri Feb 8 07:45:40 CET 2008


Author: jeffrey.yasskin
Date: Fri Feb  8 07:45:40 2008
New Revision: 60667

Modified:
   python/trunk/Lib/numbers.py
   python/trunk/Lib/test/test_rational.py
Log:
Oops! 2.6's Rational.__ne__ didn't work.


Modified: python/trunk/Lib/numbers.py
==============================================================================
--- python/trunk/Lib/numbers.py	(original)
+++ python/trunk/Lib/numbers.py	Fri Feb  8 07:45:40 2008
@@ -174,7 +174,10 @@
         """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)
 

Modified: python/trunk/Lib/test/test_rational.py
==============================================================================
--- python/trunk/Lib/test/test_rational.py	(original)
+++ python/trunk/Lib/test/test_rational.py	Fri Feb  8 07:45:40 2008
@@ -313,6 +313,8 @@
         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))


More information about the Python-checkins mailing list