diff options
| author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2012-06-15 20:19:47 -0400 |
|---|---|---|
| committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2012-06-15 20:19:47 -0400 |
| commit | 0831382d69890eeab58f43588887058a52a1f4b5 (patch) | |
| tree | f749634dbfbc248dec21b74d676f28c3b23a605e /Modules/_datetimemodule.c | |
| parent | ea0b8239401123fa7f41c74f6fc9ded1cf74088a (diff) | |
| download | cpython-git-0831382d69890eeab58f43588887058a52a1f4b5.tar.gz | |
Issue #15006: Allow equality comparison between naive and aware time
or datetime objects.
Diffstat (limited to 'Modules/_datetimemodule.c')
| -rw-r--r-- | Modules/_datetimemodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 31501242d1..d3a502db91 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 " |
