[Python-checkins] r84821 - python/branches/py3k/Lib/functools.py

raymond.hettinger python-checkins at python.org
Wed Sep 15 00:55:13 CEST 2010


Author: raymond.hettinger
Date: Wed Sep 15 00:55:13 2010
New Revision: 84821

Log:
Future proof total_ordering against changes in methods defined on object.

Modified:
   python/branches/py3k/Lib/functools.py

Modified: python/branches/py3k/Lib/functools.py
==============================================================================
--- python/branches/py3k/Lib/functools.py	(original)
+++ python/branches/py3k/Lib/functools.py	Wed Sep 15 00:55:13 2010
@@ -82,7 +82,7 @@
                    ('__lt__', lambda self, other: not self >= other)]
     }
     # Find comparisons not inherited from object.
-    roots = [op for op in convert if getattr(cls, op) is not getattr(object, op)]
+    roots = [op for op in convert if getattr(cls, op, None) is not getattr(object, op, None)]
     if not roots:
         raise ValueError('must define at least one ordering operation: < > <= >=')
     root = max(roots)       # prefer __lt__ to __le__ to __gt__ to __ge__


More information about the Python-checkins mailing list