Issue #15006: Allow equality comparison between naive and aware time
or datetime objects.
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 3150124..d3a502d 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -3707,6 +3707,14 @@
TIME_GET_MICROSECOND(other);
result = diff_to_bool(diff, op);
}
+ else if (op == Py_EQ) {
+ result = Py_False;
+ Py_INCREF(result);
+ }
+ else if (op == Py_NE) {
+ result = Py_True;
+ Py_INCREF(result);
+ }
else {
PyErr_SetString(PyExc_TypeError,
"can't compare offset-naive and "
@@ -4584,6 +4592,14 @@
Py_DECREF(delta);
result = diff_to_bool(diff, op);
}
+ else if (op == Py_EQ) {
+ result = Py_False;
+ Py_INCREF(result);
+ }
+ else if (op == Py_NE) {
+ result = Py_True;
+ Py_INCREF(result);
+ }
else {
PyErr_SetString(PyExc_TypeError,
"can't compare offset-naive and "