diff options
author | Brian Curtin <brian@python.org> | 2011-08-11 01:28:54 (GMT) |
---|---|---|
committer | Brian Curtin <brian@python.org> | 2011-08-11 01:28:54 (GMT) |
commit | dfc80e3d97680ee26e509daba4a08502fefe22ee (patch) | |
tree | f28c4978ce126c4308a45aa594f0f2c86dfc1965 /Modules | |
parent | 7d2f9e13424fe74814e14cf92d7bbd779917a5c5 (diff) | |
download | cpython-dfc80e3d97680ee26e509daba4a08502fefe22ee.zip cpython-dfc80e3d97680ee26e509daba4a08502fefe22ee.tar.gz cpython-dfc80e3d97680ee26e509daba4a08502fefe22ee.tar.bz2 |
Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
The macro was introduced in #12724.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_collectionsmodule.c | 3 | ||||
-rw-r--r-- | Modules/_datetimemodule.c | 59 | ||||
-rw-r--r-- | Modules/_sqlite/row.c | 10 | ||||
-rw-r--r-- | Modules/arraymodule.c | 6 | ||||
-rw-r--r-- | Modules/posixmodule.c | 10 | ||||
-rw-r--r-- | Modules/xxlimited.c | 3 |
6 files changed, 33 insertions, 58 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 8743408..156ad18 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -832,8 +832,7 @@ deque_richcompare(PyObject *v, PyObject *w, int op) if (!PyObject_TypeCheck(v, &deque_type) || !PyObject_TypeCheck(w, &deque_type)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + Py_RETURN_NOTIMPLEMENTED; } /* Shortcuts */ diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 747be45..718dfe2 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -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)) { diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 3d44094..b50658c 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -173,10 +173,9 @@ static Py_hash_t pysqlite_row_hash(pysqlite_Row *self) static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, int opid) { - if (opid != Py_EQ && opid != Py_NE) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } + if (opid != Py_EQ && opid != Py_NE) + Py_RETURN_NOTIMPLEMENTED; + if (PyType_IsSubtype(Py_TYPE(_other), &pysqlite_RowType)) { pysqlite_Row *other = (pysqlite_Row *)_other; PyObject *res = PyObject_RichCompare(self->description, other->description, opid); @@ -186,8 +185,7 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, return PyObject_RichCompare(self->data, other->data, opid); } } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + Py_RETURN_NOTIMPLEMENTED; } PyMappingMethods pysqlite_row_as_mapping = { diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index ae68c15..81c9c36 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -514,10 +514,8 @@ array_richcompare(PyObject *v, PyObject *w, int op) Py_ssize_t i, k; PyObject *res; - if (!array_Check(v) || !array_Check(w)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } + if (!array_Check(v) || !array_Check(w)) + Py_RETURN_NOTIMPLEMENTED; va = (arrayobject *)v; wa = (arrayobject *)w; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2be5ec9..d701690 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4925,10 +4925,9 @@ cpu_set_richcompare(Py_cpu_set *set, Py_cpu_set *other, int op) { int eq; - if ((op != Py_EQ && op != Py_NE) || Py_TYPE(other) != &cpu_set_type) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } + if ((op != Py_EQ && op != Py_NE) || Py_TYPE(other) != &cpu_set_type) + Py_RETURN_NOTIMPLEMENTED; + eq = set->ncpus == other->ncpus && CPU_EQUAL_S(set->size, set->set, other->set); if ((op == Py_EQ) ? eq : !eq) Py_RETURN_TRUE; @@ -4949,8 +4948,7 @@ cpu_set_richcompare(Py_cpu_set *set, Py_cpu_set *other, int op) } \ if (Py_TYPE(right) != &cpu_set_type || left->ncpus != right->ncpus) { \ Py_DECREF(res); \ - Py_INCREF(Py_NotImplemented); \ - return Py_NotImplemented; \ + Py_RETURN_NOTIMPLEMENTED; \ } \ assert(left->size == right->size && right->size == res->size); \ op(res->size, res->set, left->set, right->set); \ diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c index ec924f2..661b6e2 100644 --- a/Modules/xxlimited.c +++ b/Modules/xxlimited.c @@ -187,8 +187,7 @@ static PyType_Spec Str_Type_spec = { static PyObject * null_richcompare(PyObject *self, PyObject *other, int op) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + Py_RETURN_NOTIMPLEMENTED; } static PyType_Slot Null_Type_slots[] = { |