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:
Serhiy Storchaka 2019-08-04 12:38:46 +03:00 committed by GitHub
parent 5c72badd06
commit 17e52649c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 84 deletions

View file

@ -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);
}