Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56de7e2

Browse files
committed
Issue 8361: Remove assert from functools.total_ordering
1 parent c075f07 commit 56de7e2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/functools.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ def total_ordering(cls):
6767
('__lt__', lambda self, other: not self >= other)]
6868
}
6969
roots = set(dir(cls)) & set(convert)
70-
assert roots, 'must define at least one ordering operation: < > <= >='
71-
root = max(roots) # prefer __lt __ to __le__ to __gt__ to __ge__
70+
if not roots:
71+
raise ValueError('must define at least one ordering operation: < > <= >=')
72+
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
7273
for opname, opfunc in convert[root]:
7374
if opname not in roots:
7475
opfunc.__name__ = opname

0 commit comments

Comments
 (0)