summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorMojoVampire <shadowranger+github@gmail.com>2020-03-03 18:50:17 (GMT)
committerGitHub <noreply@github.com>2020-03-03 18:50:17 (GMT)
commit469325c30e147680543b2f5118b83fd95055a499 (patch)
treec10fd8f26059cb0e6caef9a7c081d324e4146969 /Lib/functools.py
parentae75a294352e9b9487f5dc8e88f068e7e6974dc2 (diff)
downloadcpython-469325c30e147680543b2f5118b83fd95055a499.zip
cpython-469325c30e147680543b2f5118b83fd95055a499.tar.gz
cpython-469325c30e147680543b2f5118b83fd95055a499.tar.bz2
bpo-35712: Make using NotImplemented in a boolean context issue a deprecation warning (GH-13195)
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 535fa04..e230175 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -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):