From e6b46aafad3427463d6264a68824df4797e682f1 Mon Sep 17 00:00:00 2001 From: Xtreak Date: Sat, 13 Jul 2019 18:52:21 +0530 Subject: 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 --- Lib/datetime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/datetime.py') diff --git a/Lib/datetime.py b/Lib/datetime.py index 0e64815944..e35ee0554c 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): -- cgit v1.2.1