mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-37685: Fixed comparisons of datetime.timedelta and datetime.timezone. (GH-14996)
There was a discrepancy between the Python and C implementations. Add singletons ALWAYS_EQ, LARGEST and SMALLEST in test.support to test mixed type comparison.
This commit is contained in:
parent
5c72badd06
commit
17e52649c0
7 changed files with 107 additions and 84 deletions
|
@ -3741,11 +3741,8 @@ timezone_richcompare(PyDateTime_TimeZone *self,
|
|||
{
|
||||
if (op != Py_EQ && op != Py_NE)
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
if (Py_TYPE(other) != &PyDateTime_TimeZoneType) {
|
||||
if (op == Py_EQ)
|
||||
Py_RETURN_FALSE;
|
||||
else
|
||||
Py_RETURN_TRUE;
|
||||
if (!PyTZInfo_Check(other)) {
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
return delta_richcompare(self->offset, other->offset, op);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue