summaryrefslogtreecommitdiffstats
path: root/Lib/datetime.py
diff options
context:
space:
mode:
authorXtreak <tir.karthi@gmail.com>2019-07-14 10:13:59 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-14 10:13:59 (GMT)
commitc6b31061997526b31961ec34328408ca421f51fc (patch)
treeda14b1cae73b44b96bc93c7c3c4fcca2417daec9 /Lib/datetime.py
parent5631e381a6fbc471896b5562d542be0a6befa797 (diff)
downloadcpython-c6b31061997526b31961ec34328408ca421f51fc.zip
cpython-c6b31061997526b31961ec34328408ca421f51fc.tar.gz
cpython-c6b31061997526b31961ec34328408ca421f51fc.tar.bz2
[3.7] bpo-37579: Improve equality behavior for pure Python datetime and time (GH-14726) (GH-14745)
Returns NotImplemented for timedelta and time in __eq__ for different types in Python implementation, which matches the C implementation. This also adds tests to enforce that these objects will fall back to the right hand side's __eq__ and/or __ne__ implementation. [bpo-37579](https://bugs.python.org/issue37579) (cherry picked from commit e6b46aafad3427463d6264a68824df4797e682f1) Co-authored-by: Xtreak <tir.karthi@gmail.com> https://bugs.python.org/issue37579
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r--Lib/datetime.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py
index a964b20..03beb05 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -718,7 +718,7 @@ class timedelta:
if isinstance(other, timedelta):
return self._cmp(other) == 0
else:
- return False
+ return NotImplemented
def __le__(self, other):
if isinstance(other, timedelta):
@@ -1261,7 +1261,7 @@ class time:
if isinstance(other, time):
return self._cmp(other, allow_mixed=True) == 0
else:
- return False
+ return NotImplemented
def __le__(self, other):
if isinstance(other, time):