mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-35712: Make using NotImplemented in a boolean context issue a deprecation warning (GH-13195)
This commit is contained in:
parent
ae75a29435
commit
469325c30e
10 changed files with 64 additions and 12 deletions
|
@ -96,6 +96,8 @@ def _gt_from_lt(self, other, NotImplemented=NotImplemented):
|
|||
def _le_from_lt(self, other, NotImplemented=NotImplemented):
|
||||
'Return a <= b. Computed by @total_ordering from (a < b) or (a == b).'
|
||||
op_result = self.__lt__(other)
|
||||
if op_result is NotImplemented:
|
||||
return op_result
|
||||
return op_result or self == other
|
||||
|
||||
def _ge_from_lt(self, other, NotImplemented=NotImplemented):
|
||||
|
@ -136,6 +138,8 @@ def _lt_from_gt(self, other, NotImplemented=NotImplemented):
|
|||
def _ge_from_gt(self, other, NotImplemented=NotImplemented):
|
||||
'Return a >= b. Computed by @total_ordering from (a > b) or (a == b).'
|
||||
op_result = self.__gt__(other)
|
||||
if op_result is NotImplemented:
|
||||
return op_result
|
||||
return op_result or self == other
|
||||
|
||||
def _le_from_gt(self, other, NotImplemented=NotImplemented):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue