summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-14 22:55:13 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-14 22:55:13 (GMT)
commit1006bd459bc1cdd2aeb1762fadc6cc64d62c819f (patch)
treeccdae438b7a08eda168445d3b555fdeb5014773a /Lib/functools.py
parent2e55fec14c7e91d17760b966f19c41634b5a12fd (diff)
downloadcpython-1006bd459bc1cdd2aeb1762fadc6cc64d62c819f.zip
cpython-1006bd459bc1cdd2aeb1762fadc6cc64d62c819f.tar.gz
cpython-1006bd459bc1cdd2aeb1762fadc6cc64d62c819f.tar.bz2
Future proof total_ordering against changes in methods defined on object.
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index b39e77e..314c0dd 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -82,7 +82,7 @@ def total_ordering(cls):
('__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__