summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c12
-rw-r--r--Objects/funcobject.c3
-rw-r--r--Objects/setobject.c9
3 files changed, 8 insertions, 16 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index b2962fd137..0ba6fb5b76 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;
}
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 7f5a71ab43..80117bfb20 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -45,8 +45,7 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname
PyThreadState *tstate = _PyThreadState_GET();
- PyCodeObject *code_obj = (PyCodeObject *)code;
- Py_INCREF(code_obj);
+ PyCodeObject *code_obj = (PyCodeObject *)Py_NewRef(code);
PyObject *name = code_obj->co_name;
assert(name != NULL);
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 3c510b5d1a..e064676838 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1601,8 +1601,7 @@ set_isub(PySetObject *so, PyObject *other)
Py_RETURN_NOTIMPLEMENTED;
if (set_difference_update_internal(so, other))
return NULL;
- Py_INCREF(so);
- return (PyObject *)so;
+ return Py_NewRef(so);
}
static PyObject *
@@ -1639,8 +1638,7 @@ set_symmetric_difference_update(PySetObject *so, PyObject *other)
}
if (PyAnySet_Check(other)) {
- Py_INCREF(other);
- otherset = (PySetObject *)other;
+ otherset = (PySetObject *)Py_NewRef(other);
} else {
otherset = (PySetObject *)make_new_set_basetype(Py_TYPE(so), other);
if (otherset == NULL)
@@ -1715,8 +1713,7 @@ set_ixor(PySetObject *so, PyObject *other)
if (result == NULL)
return NULL;
Py_DECREF(result);
- Py_INCREF(so);
- return (PyObject *)so;
+ return Py_NewRef(so);
}
static PyObject *