|
45 | 45 | #include "numpy/ndarraytypes.h"
|
46 | 46 | #include "numpy/npy_3kcompat.h"
|
47 | 47 | #include "common.h"
|
| 48 | +#include "npy_pycompat.h" |
48 | 49 |
|
49 | 50 | #include "dispatching.h"
|
50 | 51 | #include "dtypemeta.h"
|
@@ -121,8 +122,9 @@ PyUFunc_AddLoop(PyUFuncObject *ufunc, PyObject *info, int ignore_duplicate)
|
121 | 122 | PyObject *loops = ufunc->_loops;
|
122 | 123 | Py_ssize_t length = PyList_Size(loops);
|
123 | 124 | for (Py_ssize_t i = 0; i < length; i++) {
|
124 |
| - PyObject *item = PyList_GetItem(loops, i); |
| 125 | + PyObject *item = PyList_GetItemRef(loops, i); |
125 | 126 | PyObject *cur_DType_tuple = PyTuple_GetItem(item, 0);
|
| 127 | + Py_DECREF(item); |
126 | 128 | int cmp = PyObject_RichCompareBool(cur_DType_tuple, DType_tuple, Py_EQ);
|
127 | 129 | if (cmp < 0) {
|
128 | 130 | return -1;
|
@@ -1277,8 +1279,9 @@ get_info_no_cast(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtype,
|
1277 | 1279 | PyObject *loops = ufunc->_loops;
|
1278 | 1280 | Py_ssize_t length = PyList_Size(loops);
|
1279 | 1281 | for (Py_ssize_t i = 0; i < length; i++) {
|
1280 |
| - PyObject *item = PyList_GetItem(loops, i); |
| 1282 | + PyObject *item = PyList_GetItemRef(loops, i); |
1281 | 1283 | PyObject *cur_DType_tuple = PyTuple_GetItem(item, 0);
|
| 1284 | + Py_DECREF(item); |
1282 | 1285 | int cmp = PyObject_RichCompareBool(cur_DType_tuple,
|
1283 | 1286 | t_dtypes, Py_EQ);
|
1284 | 1287 | if (cmp < 0) {
|
|
0 commit comments