mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
gh-139327: consolidate sqlite3_finalize and sqlite3_reset usages (GH-139329)
This commit is contained in:
parent
4126d9f1ab
commit
27acaf1cb7
5 changed files with 113 additions and 16 deletions
|
|
@ -103,7 +103,12 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
|
|||
return self;
|
||||
|
||||
error:
|
||||
(void)sqlite3_finalize(stmt);
|
||||
assert(PyErr_Occurred());
|
||||
if (sqlite3_finalize(stmt) != SQLITE_OK) {
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
PyErr_SetString(connection->InternalError, "cannot finalize statement");
|
||||
_PyErr_ChainExceptions1(exc);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -114,10 +119,16 @@ stmt_dealloc(PyObject *op)
|
|||
PyTypeObject *tp = Py_TYPE(self);
|
||||
PyObject_GC_UnTrack(op);
|
||||
if (self->st) {
|
||||
int rc;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
sqlite3_finalize(self->st);
|
||||
rc = sqlite3_finalize(self->st);
|
||||
Py_END_ALLOW_THREADS
|
||||
self->st = 0;
|
||||
self->st = NULL;
|
||||
if (rc != SQLITE_OK) {
|
||||
pysqlite_state *state = PyType_GetModuleState(Py_TYPE(op));
|
||||
PyErr_SetString(state->InternalError, "cannot finalize statement");
|
||||
PyErr_FormatUnraisable("Exception ignored in stmt_dealloc()");
|
||||
}
|
||||
}
|
||||
tp->tp_free(self);
|
||||
Py_DECREF(tp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue