gh-99300: Use Py_NewRef() in Modules/ directory (#99440)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
This commit is contained in:
Victor Stinner 2022-11-13 16:04:33 +01:00 committed by GitHub
parent 0bedc28d14
commit bbba3f3f43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 82 deletions

View file

@ -1524,8 +1524,7 @@ ndarray_getbuf(NDArrayObject *self, Py_buffer *view, int flags)
return -1;
}
view->obj = (PyObject *)self;
Py_INCREF(view->obj);
view->obj = Py_NewRef(self);
self->head->exports++;
return 0;
@ -2021,8 +2020,7 @@ ndarray_get_obj(NDArrayObject *self, void *closure)
if (base->obj == NULL) {
Py_RETURN_NONE;
}
Py_INCREF(base->obj);
return base->obj;
return Py_NewRef(base->obj);
}
static PyObject *
@ -2559,8 +2557,7 @@ result:
PyBuffer_Release(&v2);
ret = equal ? Py_True : Py_False;
Py_INCREF(ret);
return ret;
return Py_NewRef(ret);
}
static PyObject *
@ -2597,8 +2594,7 @@ is_contiguous(PyObject *self, PyObject *args)
PyBuffer_Release(&view);
}
Py_INCREF(ret);
return ret;
return Py_NewRef(ret);
}
static Py_hash_t
@ -2748,8 +2744,7 @@ staticarray_getbuf(StaticArrayObject *self, Py_buffer *view, int flags)
view->obj = NULL; /* Don't use this in new code. */
}
else {
view->obj = (PyObject *)self;
Py_INCREF(view->obj);
view->obj = Py_NewRef(self);
}
return 0;