mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
bpo-1635741: sqlite3 uses Py_NewRef/Py_XNewRef (GH-23170)
This commit is contained in:
parent
3ccef1ca47
commit
bf64d9064a
7 changed files with 45 additions and 82 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue