summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/row.c
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2020-12-27 11:05:33 (GMT)
committerGitHub <noreply@github.com>2020-12-27 11:05:33 (GMT)
commitbf64d9064ab641b1ef9a0c4bda097ebf1204faf4 (patch)
tree087d470d6d608bedff06e712fa7b85ffb59a4359 /Modules/_sqlite/row.c
parent3ccef1ca474592e191a00e131dfbaf777db271e9 (diff)
downloadcpython-bf64d9064ab641b1ef9a0c4bda097ebf1204faf4.zip
cpython-bf64d9064ab641b1ef9a0c4bda097ebf1204faf4.tar.gz
cpython-bf64d9064ab641b1ef9a0c4bda097ebf1204faf4.tar.bz2
bpo-1635741: sqlite3 uses Py_NewRef/Py_XNewRef (GH-23170)
Diffstat (limited to 'Modules/_sqlite/row.c')
-rw-r--r--Modules/_sqlite/row.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 76b6f04..9086c19 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -63,20 +63,16 @@ pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
if (self == NULL)
return NULL;
- Py_INCREF(data);
- self->data = data;
-
- Py_INCREF(cursor->description);
- self->description = cursor->description;
+ self->data = Py_NewRef(data);
+ self->description = Py_NewRef(cursor->description);
return (PyObject *) self;
}
PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx)
{
- PyObject* item = PyTuple_GetItem(self->data, idx);
- Py_XINCREF(item);
- return item;
+ PyObject *item = PyTuple_GetItem(self->data, idx);
+ return Py_XNewRef(item);
}
static int
@@ -111,7 +107,6 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
{
Py_ssize_t _idx;
Py_ssize_t nitems, i;
- PyObject* item;
if (PyLong_Check(idx)) {
_idx = PyNumber_AsSsize_t(idx, PyExc_IndexError);
@@ -119,9 +114,9 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
return NULL;
if (_idx < 0)
_idx += PyTuple_GET_SIZE(self->data);
- item = PyTuple_GetItem(self->data, _idx);
- Py_XINCREF(item);
- return item;
+
+ PyObject *item = PyTuple_GetItem(self->data, _idx);
+ return Py_XNewRef(item);
} else if (PyUnicode_Check(idx)) {
nitems = PyTuple_Size(self->description);
@@ -135,9 +130,8 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
}
if (eq) {
/* found item */
- item = PyTuple_GetItem(self->data, i);
- Py_INCREF(item);
- return item;
+ PyObject *item = PyTuple_GetItem(self->data, i);
+ return Py_XNewRef(item);
}
}