Commit 4e45512d authored by Raymond Hettinger's avatar Raymond Hettinger

Issue 8361: Remove assert from functools.total_ordering

parent 55b21389
...@@ -67,8 +67,9 @@ def total_ordering(cls): ...@@ -67,8 +67,9 @@ def total_ordering(cls):
('__lt__', lambda self, other: not self >= other)] ('__lt__', lambda self, other: not self >= other)]
} }
roots = set(dir(cls)) & set(convert) roots = set(dir(cls)) & set(convert)
assert roots, 'must define at least one ordering operation: < > <= >=' if not roots:
root = max(roots) # prefer __lt __ to __le__ to __gt__ to __ge__ raise ValueError('must define at least one ordering operation: < > <= >=')
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
for opname, opfunc in convert[root]: for opname, opfunc in convert[root]:
if opname not in roots: if opname not in roots:
opfunc.__name__ = opname opfunc.__name__ = opname
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment