| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7d2f9e1 commit dfc80e3
24 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -832,8 +832,7 @@ deque_richcompare(PyObject *v, PyObject *w, int op) | |||
| 832 | 832 | ||
| 833 | 833 | if (!PyObject_TypeCheck(v, &deque_type) || | |
| 834 | 834 | !PyObject_TypeCheck(w, &deque_type)) { | |
| 835 | - Py_INCREF(Py_NotImplemented); | ||
| 836 | - return Py_NotImplemented; | ||
| 835 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 837 | 836 | } | |
| 838 | 837 | ||
| 839 | 838 | /* Shortcuts */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1812,8 +1812,7 @@ delta_richcompare(PyObject *self, PyObject *other, int op) | |||
| 1812 | 1812 | return diff_to_bool(diff, op); | |
| 1813 | 1813 | } | |
| 1814 | 1814 | else { | |
| 1815 | - Py_INCREF(Py_NotImplemented); | ||
| 1816 | - return Py_NotImplemented; | ||
| 1815 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 1817 | 1816 | } | |
| 1818 | 1817 | } | |
| 1819 | 1818 | ||
@@ -1911,10 +1910,8 @@ delta_remainder(PyObject *left, PyObject *right) | |||
| 1911 | 1910 | PyObject *pyus_remainder; | |
| 1912 | 1911 | PyObject *remainder; | |
| 1913 | 1912 | ||
| 1914 | - if (!PyDelta_Check(left) || !PyDelta_Check(right)) { | ||
| 1915 | - Py_INCREF(Py_NotImplemented); | ||
| 1916 | - return Py_NotImplemented; | ||
| 1917 | - } | ||
| 1913 | + if (!PyDelta_Check(left) || !PyDelta_Check(right)) | ||
| 1914 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 1918 | 1915 | ||
| 1919 | 1916 | pyus_left = delta_to_microseconds((PyDateTime_Delta *)left); | |
| 1920 | 1917 | if (pyus_left == NULL) | |
@@ -1949,10 +1946,8 @@ delta_divmod(PyObject *left, PyObject *right) | |||
| 1949 | 1946 | PyObject *delta; | |
| 1950 | 1947 | PyObject *result; | |
| 1951 | 1948 | ||
| 1952 | - if (!PyDelta_Check(left) || !PyDelta_Check(right)) { | ||
| 1953 | - Py_INCREF(Py_NotImplemented); | ||
| 1954 | - return Py_NotImplemented; | ||
| 1955 | - } | ||
| 1949 | + if (!PyDelta_Check(left) || !PyDelta_Check(right)) | ||
| 1950 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 1956 | 1951 | ||
| 1957 | 1952 | pyus_left = delta_to_microseconds((PyDateTime_Delta *)left); | |
| 1958 | 1953 | if (pyus_left == NULL) | |
@@ -2546,10 +2541,9 @@ add_date_timedelta(PyDateTime_Date *date, PyDateTime_Delta *delta, int negate) | |||
| 2546 | 2541 | static PyObject * | |
| 2547 | 2542 | date_add(PyObject *left, PyObject *right) | |
| 2548 | 2543 | { | |
| 2549 | - if (PyDateTime_Check(left) || PyDateTime_Check(right)) { | ||
| 2550 | - Py_INCREF(Py_NotImplemented); | ||
| 2551 | - return Py_NotImplemented; | ||
| 2552 | - } | ||
| 2544 | + if (PyDateTime_Check(left) || PyDateTime_Check(right)) | ||
| 2545 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 2546 | + | ||
| 2553 | 2547 | if (PyDate_Check(left)) { | |
| 2554 | 2548 | /* date + ??? */ | |
| 2555 | 2549 | if (PyDelta_Check(right)) | |
@@ -2568,17 +2562,15 @@ date_add(PyObject *left, PyObject *right) | |||
| 2568 | 2562 | (PyDateTime_Delta *) left, | |
| 2569 | 2563 | 0); | |
| 2570 | 2564 | } | |
| 2571 | - Py_INCREF(Py_NotImplemented); | ||
| 2572 | - return Py_NotImplemented; | ||
| 2565 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 2573 | 2566 | } | |
| 2574 | 2567 | ||
| 2575 | 2568 | static PyObject * | |
| 2576 | 2569 | date_subtract(PyObject *left, PyObject *right) | |
| 2577 | 2570 | { | |
| 2578 | - if (PyDateTime_Check(left) || PyDateTime_Check(right)) { | ||
| 2579 | - Py_INCREF(Py_NotImplemented); | ||
| 2580 | - return Py_NotImplemented; | ||
| 2581 | - } | ||
| 2571 | + if (PyDateTime_Check(left) || PyDateTime_Check(right)) | ||
| 2572 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 2573 | + | ||
| 2582 | 2574 | if (PyDate_Check(left)) { | |
| 2583 | 2575 | if (PyDate_Check(right)) { | |
| 2584 | 2576 | /* date - date */ | |
@@ -2597,8 +2589,7 @@ date_subtract(PyObject *left, PyObject *right) | |||
| 2597 | 2589 | 1); | |
| 2598 | 2590 | } | |
| 2599 | 2591 | } | |
| 2600 | - Py_INCREF(Py_NotImplemented); | ||
| 2601 | - return Py_NotImplemented; | ||
| 2592 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 2602 | 2593 | } | |
| 2603 | 2594 | ||
| 2604 | 2595 | ||
@@ -2715,10 +2706,8 @@ date_richcompare(PyObject *self, PyObject *other, int op) | |||
| 2715 | 2706 | _PyDateTime_DATE_DATASIZE); | |
| 2716 | 2707 | return diff_to_bool(diff, op); | |
| 2717 | 2708 | } | |
| 2718 | - else { | ||
| 2719 | - Py_INCREF(Py_NotImplemented); | ||
| 2720 | - return Py_NotImplemented; | ||
| 2721 | - } | ||
| 2709 | + else | ||
| 2710 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 2722 | 2711 | } | |
| 2723 | 2712 | ||
| 2724 | 2713 | static PyObject * | |
@@ -3215,10 +3204,8 @@ static PyObject * | |||
| 3215 | 3204 | timezone_richcompare(PyDateTime_TimeZone *self, | |
| 3216 | 3205 | PyDateTime_TimeZone *other, int op) | |
| 3217 | 3206 | { | |
| 3218 | - if (op != Py_EQ && op != Py_NE) { | ||
| 3219 | - Py_INCREF(Py_NotImplemented); | ||
| 3220 | - return Py_NotImplemented; | ||
| 3221 | - } | ||
| 3207 | + if (op != Py_EQ && op != Py_NE) | ||
| 3208 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 3222 | 3209 | return delta_richcompare(self->offset, other->offset, op); | |
| 3223 | 3210 | } | |
| 3224 | 3211 | ||
@@ -3664,10 +3651,8 @@ time_richcompare(PyObject *self, PyObject *other, int op) | |||
| 3664 | 3651 | PyObject *offset1, *offset2; | |
| 3665 | 3652 | int diff; | |
| 3666 | 3653 | ||
| 3667 | - if (! PyTime_Check(other)) { | ||
| 3668 | - Py_INCREF(Py_NotImplemented); | ||
| 3669 | - return Py_NotImplemented; | ||
| 3670 | - } | ||
| 3654 | + if (! PyTime_Check(other)) | ||
| 3655 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 3671 | 3656 | ||
| 3672 | 3657 | if (GET_TIME_TZINFO(self) == GET_TIME_TZINFO(other)) { | |
| 3673 | 3658 | diff = memcmp(((PyDateTime_Time *)self)->data, | |
@@ -4356,8 +4341,7 @@ datetime_add(PyObject *left, PyObject *right) | |||
| 4356 | 4341 | (PyDateTime_Delta *) left, | |
| 4357 | 4342 | 1); | |
| 4358 | 4343 | } | |
| 4359 | - Py_INCREF(Py_NotImplemented); | ||
| 4360 | - return Py_NotImplemented; | ||
| 4344 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 4361 | 4345 | } | |
| 4362 | 4346 | ||
| 4363 | 4347 | static PyObject * | |
@@ -4559,8 +4543,7 @@ datetime_richcompare(PyObject *self, PyObject *other, int op) | |||
| 4559 | 4543 | Py_RETURN_TRUE; | |
| 4560 | 4544 | return cmperror(self, other); | |
| 4561 | 4545 | } | |
| 4562 | - Py_INCREF(Py_NotImplemented); | ||
| 4563 | - return Py_NotImplemented; | ||
| 4546 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 4564 | 4547 | } | |
| 4565 | 4548 | ||
| 4566 | 4549 | if (GET_DT_TZINFO(self) == GET_DT_TZINFO(other)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,10 +173,9 @@ static Py_hash_t pysqlite_row_hash(pysqlite_Row *self) | |||
| 173 | 173 | ||
| 174 | 174 | static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, int opid) | |
| 175 | 175 | { | |
| 176 | - if (opid != Py_EQ && opid != Py_NE) { | ||
| 177 | - Py_INCREF(Py_NotImplemented); | ||
| 178 | - return Py_NotImplemented; | ||
| 179 | - } | ||
| 176 | + if (opid != Py_EQ && opid != Py_NE) | ||
| 177 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 178 | + | ||
| 180 | 179 | if (PyType_IsSubtype(Py_TYPE(_other), &pysqlite_RowType)) { | |
| 181 | 180 | pysqlite_Row *other = (pysqlite_Row *)_other; | |
| 182 | 181 | PyObject *res = PyObject_RichCompare(self->description, other->description, opid); | |
@@ -186,8 +185,7 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, | |||
| 186 | 185 | return PyObject_RichCompare(self->data, other->data, opid); | |
| 187 | 186 | } | |
| 188 | 187 | } | |
| 189 | - Py_INCREF(Py_NotImplemented); | ||
| 190 | - return Py_NotImplemented; | ||
| 188 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 191 | 189 | } | |
| 192 | 190 | ||
| 193 | 191 | PyMappingMethods pysqlite_row_as_mapping = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -514,10 +514,8 @@ array_richcompare(PyObject *v, PyObject *w, int op) | |||
| 514 | 514 | Py_ssize_t i, k; | |
| 515 | 515 | PyObject *res; | |
| 516 | 516 | ||
| 517 | - if (!array_Check(v) || !array_Check(w)) { | ||
| 518 | - Py_INCREF(Py_NotImplemented); | ||
| 519 | - return Py_NotImplemented; | ||
| 520 | - } | ||
| 517 | + if (!array_Check(v) || !array_Check(w)) | ||
| 518 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 521 | 519 | ||
| 522 | 520 | va = (arrayobject *)v; | |
| 523 | 521 | wa = (arrayobject *)w; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4925,10 +4925,9 @@ cpu_set_richcompare(Py_cpu_set *set, Py_cpu_set *other, int op) | |||
| 4925 | 4925 | { | |
| 4926 | 4926 | int eq; | |
| 4927 | 4927 | ||
| 4928 | - if ((op != Py_EQ && op != Py_NE) || Py_TYPE(other) != &cpu_set_type) { | ||
| 4929 | - Py_INCREF(Py_NotImplemented); | ||
| 4930 | - return Py_NotImplemented; | ||
| 4931 | - } | ||
| 4928 | + if ((op != Py_EQ && op != Py_NE) || Py_TYPE(other) != &cpu_set_type) | ||
| 4929 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 4930 | + | ||
| 4932 | 4931 | eq = set->ncpus == other->ncpus && CPU_EQUAL_S(set->size, set->set, other->set); | |
| 4933 | 4932 | if ((op == Py_EQ) ? eq : !eq) | |
| 4934 | 4933 | Py_RETURN_TRUE; | |
@@ -4949,8 +4948,7 @@ cpu_set_richcompare(Py_cpu_set *set, Py_cpu_set *other, int op) | |||
| 4949 | 4948 | } \ | |
| 4950 | 4949 | if (Py_TYPE(right) != &cpu_set_type || left->ncpus != right->ncpus) { \ | |
| 4951 | 4950 | Py_DECREF(res); \ | |
| 4952 | - Py_INCREF(Py_NotImplemented); \ | ||
| 4953 | - return Py_NotImplemented; \ | ||
| 4951 | + Py_RETURN_NOTIMPLEMENTED; \ | ||
| 4954 | 4952 | } \ | |
| 4955 | 4953 | assert(left->size == right->size && right->size == res->size); \ | |
| 4956 | 4954 | op(res->size, res->set, left->set, right->set); \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -187,8 +187,7 @@ static PyType_Spec Str_Type_spec = { | |||
| 187 | 187 | static PyObject * | |
| 188 | 188 | null_richcompare(PyObject *self, PyObject *other, int op) | |
| 189 | 189 | { | |
| 190 | - Py_INCREF(Py_NotImplemented); | ||
| 191 | - return Py_NotImplemented; | ||
| 190 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 192 | 191 | } | |
| 193 | 192 | ||
| 194 | 193 | static PyType_Slot Null_Type_slots[] = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -793,8 +793,7 @@ binary_op1(PyObject *v, PyObject *w, const int op_slot) | |||
| 793 | 793 | return x; | |
| 794 | 794 | Py_DECREF(x); /* can't do it */ | |
| 795 | 795 | } | |
| 796 | - Py_INCREF(Py_NotImplemented); | ||
| 797 | - return Py_NotImplemented; | ||
| 796 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 798 | 797 | } | |
| 799 | 798 | ||
| 800 | 799 | static PyObject * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -964,23 +964,20 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op) | |||
| 964 | 964 | return NULL; | |
| 965 | 965 | } | |
| 966 | 966 | ||
| 967 | - Py_INCREF(Py_NotImplemented); | ||
| 968 | - return Py_NotImplemented; | ||
| 967 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 969 | 968 | } | |
| 970 | 969 | ||
| 971 | 970 | self_size = _getbuffer(self, &self_bytes); | |
| 972 | 971 | if (self_size < 0) { | |
| 973 | 972 | PyErr_Clear(); | |
| 974 | - Py_INCREF(Py_NotImplemented); | ||
| 975 | - return Py_NotImplemented; | ||
| 973 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 976 | 974 | } | |
| 977 | 975 | ||
| 978 | 976 | other_size = _getbuffer(other, &other_bytes); | |
| 979 | 977 | if (other_size < 0) { | |
| 980 | 978 | PyErr_Clear(); | |
| 981 | 979 | PyBuffer_Release(&self_bytes); | |
| 982 | - Py_INCREF(Py_NotImplemented); | ||
| 983 | - return Py_NotImplemented; | ||
| 980 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 984 | 981 | } | |
| 985 | 982 | ||
| 986 | 983 | if (self_size != other_size && (op == Py_EQ || op == Py_NE)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -190,8 +190,7 @@ method_richcompare(PyObject *self, PyObject *other, int op) | |||
| 190 | 190 | !PyMethod_Check(self) || | |
| 191 | 191 | !PyMethod_Check(other)) | |
| 192 | 192 | { | |
| 193 | - Py_INCREF(Py_NotImplemented); | ||
| 194 | - return Py_NotImplemented; | ||
| 193 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 195 | 194 | } | |
| 196 | 195 | a = (PyMethodObject *)self; | |
| 197 | 196 | b = (PyMethodObject *)other; | |
@@ -516,8 +515,7 @@ instancemethod_richcompare(PyObject *self, PyObject *other, int op) | |||
| 516 | 515 | !PyInstanceMethod_Check(self) || | |
| 517 | 516 | !PyInstanceMethod_Check(other)) | |
| 518 | 517 | { | |
| 519 | - Py_INCREF(Py_NotImplemented); | ||
| 520 | - return Py_NotImplemented; | ||
| 518 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 521 | 519 | } | |
| 522 | 520 | a = (PyInstanceMethodObject *)self; | |
| 523 | 521 | b = (PyInstanceMethodObject *)other; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -402,8 +402,7 @@ code_richcompare(PyObject *self, PyObject *other, int op) | |||
| 402 | 402 | if ((op != Py_EQ && op != Py_NE) || | |
| 403 | 403 | !PyCode_Check(self) || | |
| 404 | 404 | !PyCode_Check(other)) { | |
| 405 | - Py_INCREF(Py_NotImplemented); | ||
| 406 | - return Py_NotImplemented; | ||
| 405 | + Py_RETURN_NOTIMPLEMENTED; | ||
| 407 | 406 | } | |
| 408 | 407 | ||
| 409 | 408 | co = (PyCodeObject *)self; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments