diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-13 15:04:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-13 15:04:33 (GMT) |
commit | bbba3f3f43a23ce30e5e943b8b4af197bc844fc3 (patch) | |
tree | 56b6d1c7b749672f6bd11b3accb75245d30f2331 /Modules/_testbuffer.c | |
parent | 0bedc28d146a282b54d8f285f3ac92e06d249cb5 (diff) | |
download | cpython-bbba3f3f43a23ce30e5e943b8b4af197bc844fc3.zip cpython-bbba3f3f43a23ce30e5e943b8b4af197bc844fc3.tar.gz cpython-bbba3f3f43a23ce30e5e943b8b4af197bc844fc3.tar.bz2 |
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.
Diffstat (limited to 'Modules/_testbuffer.c')
-rw-r--r-- | Modules/_testbuffer.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c index eea9d21..bec20a1 100644 --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -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; |