summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-16 09:39:47 (GMT)
committerGitHub <noreply@github.com>2022-11-16 09:39:47 (GMT)
commit3ed8803ef59f80e03c40b100b04c2e13f138ceed (patch)
treeec9ce18edd242485d4e3198d8e62924e1616c4ea /Objects/bytearrayobject.c
parentea88d34de27ba2b3acaeb03c7dc7829dff40ea5c (diff)
downloadcpython-3ed8803ef59f80e03c40b100b04c2e13f138ceed.zip
cpython-3ed8803ef59f80e03c40b100b04c2e13f138ceed.tar.gz
cpython-3ed8803ef59f80e03c40b100b04c2e13f138ceed.tar.bz2
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99513)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index b2962fd..0ba6fb5 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -313,8 +313,7 @@ bytearray_iconcat(PyByteArrayObject *self, PyObject *other)
}
memcpy(PyByteArray_AS_STRING(self) + size, vo.buf, vo.len);
PyBuffer_Release(&vo);
- Py_INCREF(self);
- return (PyObject *)self;
+ return Py_NewRef(self);
}
static PyObject *
@@ -340,8 +339,7 @@ bytearray_irepeat(PyByteArrayObject *self, Py_ssize_t count)
if (count < 0)
count = 0;
else if (count == 1) {
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef(self);
}
const Py_ssize_t mysize = Py_SIZE(self);
@@ -354,8 +352,7 @@ bytearray_irepeat(PyByteArrayObject *self, Py_ssize_t count)
char* buf = PyByteArray_AS_STRING(self);
_PyBytes_Repeat(buf, size, buf, mysize);
- Py_INCREF(self);
- return (PyObject *)self;
+ return Py_NewRef(self);
}
static PyObject *
@@ -2477,8 +2474,7 @@ bytearray_iter(PyObject *seq)
if (it == NULL)
return NULL;
it->it_index = 0;
- Py_INCREF(seq);
- it->it_seq = (PyByteArrayObject *)seq;
+ it->it_seq = (PyByteArrayObject *)Py_NewRef(seq);
_PyObject_GC_TRACK(it);
return (PyObject *)it;
}