diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-07-13 13:59:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-13 13:59:37 (GMT) |
commit | 143672cf028740fc549e532c049559c522930c95 (patch) | |
tree | 3561a6b51b33a40d1a2fe051500f3eeb9c027f52 /Lib/datetime.py | |
parent | 5da83b417e48aecd7698387d3f37c603162fd46e (diff) | |
download | cpython-143672cf028740fc549e532c049559c522930c95.zip cpython-143672cf028740fc549e532c049559c522930c95.tar.gz cpython-143672cf028740fc549e532c049559c522930c95.tar.bz2 |
bpo-37579: Improve equality behavior for pure Python datetime and time (GH-14726)
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
(cherry picked from commit e6b46aafad3427463d6264a68824df4797e682f1)
Co-authored-by: Xtreak <tir.karthi@gmail.com>
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r-- | Lib/datetime.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py index 0e64815..e35ee05 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -733,7 +733,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): @@ -1310,7 +1310,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): |