mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
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 e6b46aafad
)
Co-authored-by: Xtreak <tir.karthi@gmail.com>
This commit is contained in:
parent
5da83b417e
commit
143672cf02
3 changed files with 26 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue