summaryrefslogtreecommitdiffstats
path: root/Modules/_datetimemodule.c
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2012-06-16 00:19:47 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2012-06-16 00:19:47 (GMT)
commit0831382d69890eeab58f43588887058a52a1f4b5 (patch)
treef749634dbfbc248dec21b74d676f28c3b23a605e /Modules/_datetimemodule.c
parentea0b8239401123fa7f41c74f6fc9ded1cf74088a (diff)
downloadcpython-0831382d69890eeab58f43588887058a52a1f4b5.zip
cpython-0831382d69890eeab58f43588887058a52a1f4b5.tar.gz
cpython-0831382d69890eeab58f43588887058a52a1f4b5.tar.bz2
Issue #15006: Allow equality comparison between naive and aware time
or datetime objects.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r--Modules/_datetimemodule.c16
1 files changed, 16 insertions, 0 deletions
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_richcompare(PyObject *self, PyObject *other, int op)
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 @@ datetime_richcompare(PyObject *self, PyObject *other, int op)
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 "