diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-12-27 12:46:59 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-12-27 12:46:59 -0500 |
commit | a78f0158a28734f965218b834ea8c0b166b7353f (patch) | |
tree | dca70268e2a41d49658e7eed783c6fc243d119cd /Modules/_sqlite/row.c | |
parent | ec8e6895a3ce9cd69b6ceb75a15fcc74d4a522dc (diff) | |
parent | bf64d9064ab641b1ef9a0c4bda097ebf1204faf4 (diff) | |
download | cpython-git-revert-23107-revert-13893-fix-issue-37193.tar.gz |
Merge branch 'master' into revert-23107-revert-13893-fix-issue-37193revert-23107-revert-13893-fix-issue-37193
Diffstat (limited to 'Modules/_sqlite/row.c')
-rw-r--r-- | Modules/_sqlite/row.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 76b6f04f0c..9086c19af7 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); } } |