mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
The macro was introduced in #12724.
This commit is contained in:
parent
7d2f9e1342
commit
dfc80e3d97
24 changed files with 87 additions and 162 deletions
|
@ -1812,8 +1812,7 @@ delta_richcompare(PyObject *self, PyObject *other, int op)
|
|||
return diff_to_bool(diff, op);
|
||||
}
|
||||
else {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1911,10 +1910,8 @@ delta_remainder(PyObject *left, PyObject *right)
|
|||
PyObject *pyus_remainder;
|
||||
PyObject *remainder;
|
||||
|
||||
if (!PyDelta_Check(left) || !PyDelta_Check(right)) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
if (!PyDelta_Check(left) || !PyDelta_Check(right))
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
|
||||
pyus_left = delta_to_microseconds((PyDateTime_Delta *)left);
|
||||
if (pyus_left == NULL)
|
||||
|
@ -1949,10 +1946,8 @@ delta_divmod(PyObject *left, PyObject *right)
|
|||
PyObject *delta;
|
||||
PyObject *result;
|
||||
|
||||
if (!PyDelta_Check(left) || !PyDelta_Check(right)) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
if (!PyDelta_Check(left) || !PyDelta_Check(right))
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
|
||||
pyus_left = delta_to_microseconds((PyDateTime_Delta *)left);
|
||||
if (pyus_left == NULL)
|
||||
|
@ -2546,10 +2541,9 @@ add_date_timedelta(PyDateTime_Date *date, PyDateTime_Delta *delta, int negate)
|
|||
static PyObject *
|
||||
date_add(PyObject *left, PyObject *right)
|
||||
{
|
||||
if (PyDateTime_Check(left) || PyDateTime_Check(right)) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
if (PyDateTime_Check(left) || PyDateTime_Check(right))
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
|
||||
if (PyDate_Check(left)) {
|
||||
/* date + ??? */
|
||||
if (PyDelta_Check(right))
|
||||
|
@ -2568,17 +2562,15 @@ date_add(PyObject *left, PyObject *right)
|
|||
(PyDateTime_Delta *) left,
|
||||
0);
|
||||
}
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
date_subtract(PyObject *left, PyObject *right)
|
||||
{
|
||||
if (PyDateTime_Check(left) || PyDateTime_Check(right)) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
if (PyDateTime_Check(left) || PyDateTime_Check(right))
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
|
||||
if (PyDate_Check(left)) {
|
||||
if (PyDate_Check(right)) {
|
||||
/* date - date */
|
||||
|
@ -2597,8 +2589,7 @@ date_subtract(PyObject *left, PyObject *right)
|
|||
1);
|
||||
}
|
||||
}
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2715,10 +2706,8 @@ date_richcompare(PyObject *self, PyObject *other, int op)
|
|||
_PyDateTime_DATE_DATASIZE);
|
||||
return diff_to_bool(diff, op);
|
||||
}
|
||||
else {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
else
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -3215,10 +3204,8 @@ static PyObject *
|
|||
timezone_richcompare(PyDateTime_TimeZone *self,
|
||||
PyDateTime_TimeZone *other, int op)
|
||||
{
|
||||
if (op != Py_EQ && op != Py_NE) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
if (op != Py_EQ && op != Py_NE)
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
return delta_richcompare(self->offset, other->offset, op);
|
||||
}
|
||||
|
||||
|
@ -3664,10 +3651,8 @@ time_richcompare(PyObject *self, PyObject *other, int op)
|
|||
PyObject *offset1, *offset2;
|
||||
int diff;
|
||||
|
||||
if (! PyTime_Check(other)) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
if (! PyTime_Check(other))
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
|
||||
if (GET_TIME_TZINFO(self) == GET_TIME_TZINFO(other)) {
|
||||
diff = memcmp(((PyDateTime_Time *)self)->data,
|
||||
|
@ -4356,8 +4341,7 @@ datetime_add(PyObject *left, PyObject *right)
|
|||
(PyDateTime_Delta *) left,
|
||||
1);
|
||||
}
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -4559,8 +4543,7 @@ datetime_richcompare(PyObject *self, PyObject *other, int op)
|
|||
Py_RETURN_TRUE;
|
||||
return cmperror(self, other);
|
||||
}
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
if (GET_DT_TZINFO(self) == GET_DT_TZINFO(other)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue