mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-99300: Use Py_NewRef() in Objects/ directory (#99354)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
This commit is contained in:
parent
1960eb005e
commit
3a1dde8f29
13 changed files with 66 additions and 128 deletions
|
@ -682,8 +682,7 @@ mbuf_add_view(_PyManagedBufferObject *mbuf, const Py_buffer *src)
|
|||
init_suboffsets(dest, src);
|
||||
init_flags(mv);
|
||||
|
||||
mv->mbuf = mbuf;
|
||||
Py_INCREF(mbuf);
|
||||
mv->mbuf = (_PyManagedBufferObject*)Py_NewRef(mbuf);
|
||||
mbuf->exports++;
|
||||
|
||||
return (PyObject *)mv;
|
||||
|
@ -713,8 +712,7 @@ mbuf_add_incomplete_view(_PyManagedBufferObject *mbuf, const Py_buffer *src,
|
|||
dest = &mv->view;
|
||||
init_shared_values(dest, src);
|
||||
|
||||
mv->mbuf = mbuf;
|
||||
Py_INCREF(mbuf);
|
||||
mv->mbuf = (_PyManagedBufferObject*)Py_NewRef(mbuf);
|
||||
mbuf->exports++;
|
||||
|
||||
return (PyObject *)mv;
|
||||
|
@ -1102,8 +1100,7 @@ static PyObject *
|
|||
memory_enter(PyObject *self, PyObject *args)
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
Py_INCREF(self);
|
||||
return self;
|
||||
return Py_NewRef(self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1515,8 +1512,7 @@ memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags)
|
|||
}
|
||||
|
||||
|
||||
view->obj = (PyObject *)self;
|
||||
Py_INCREF(view->obj);
|
||||
view->obj = Py_NewRef(self);
|
||||
self->exports++;
|
||||
|
||||
return 0;
|
||||
|
@ -2047,10 +2043,9 @@ struct_unpack_single(const char *ptr, struct unpacker *x)
|
|||
return NULL;
|
||||
|
||||
if (PyTuple_GET_SIZE(v) == 1) {
|
||||
PyObject *tmp = PyTuple_GET_ITEM(v, 0);
|
||||
Py_INCREF(tmp);
|
||||
PyObject *res = Py_NewRef(PyTuple_GET_ITEM(v, 0));
|
||||
Py_DECREF(v);
|
||||
return tmp;
|
||||
return res;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -2496,8 +2491,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
|
|||
return unpack_single(self, view->buf, fmt);
|
||||
}
|
||||
else if (key == Py_Ellipsis) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
return Py_NewRef(self);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
|
@ -2957,8 +2951,7 @@ result:
|
|||
unpacker_free(unpack_v);
|
||||
unpacker_free(unpack_w);
|
||||
|
||||
Py_XINCREF(res);
|
||||
return res;
|
||||
return Py_XNewRef(res);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -3052,8 +3045,7 @@ memory_obj_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
|||
if (view->obj == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
Py_INCREF(view->obj);
|
||||
return view->obj;
|
||||
return Py_NewRef(view->obj);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -3281,8 +3273,7 @@ memory_iter(PyObject *seq)
|
|||
it->it_fmt = fmt;
|
||||
it->it_length = memory_length(obj);
|
||||
it->it_index = 0;
|
||||
Py_INCREF(seq);
|
||||
it->it_seq = obj;
|
||||
it->it_seq = (PyMemoryViewObject*)Py_NewRef(obj);
|
||||
_PyObject_GC_TRACK(it);
|
||||
return (PyObject *)it;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue