mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00: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
|
@ -72,8 +72,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
|
|||
}
|
||||
|
||||
self->in_weakreflist = NULL;
|
||||
Py_INCREF(sql);
|
||||
self->sql = sql;
|
||||
self->sql = Py_NewRef(sql);
|
||||
|
||||
/* Determine if the statement is a DML statement.
|
||||
SELECT is the only exception. See #9924. */
|
||||
|
@ -240,11 +239,11 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
|
|||
}
|
||||
for (i = 0; i < num_params; i++) {
|
||||
if (PyTuple_CheckExact(parameters)) {
|
||||
current_param = PyTuple_GET_ITEM(parameters, i);
|
||||
Py_INCREF(current_param);
|
||||
PyObject *item = PyTuple_GET_ITEM(parameters, i);
|
||||
current_param = Py_NewRef(item);
|
||||
} else if (PyList_CheckExact(parameters)) {
|
||||
current_param = PyList_GetItem(parameters, i);
|
||||
Py_XINCREF(current_param);
|
||||
PyObject *item = PyList_GetItem(parameters, i);
|
||||
current_param = Py_XNewRef(item);
|
||||
} else {
|
||||
current_param = PySequence_GetItem(parameters, i);
|
||||
}
|
||||
|
@ -290,8 +289,8 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
|
|||
return;
|
||||
}
|
||||
if (PyDict_CheckExact(parameters)) {
|
||||
current_param = PyDict_GetItemWithError(parameters, binding_name_obj);
|
||||
Py_XINCREF(current_param);
|
||||
PyObject *item = PyDict_GetItemWithError(parameters, binding_name_obj);
|
||||
current_param = Py_XNewRef(item);
|
||||
} else {
|
||||
current_param = PyObject_GetItem(parameters, binding_name_obj);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue