bpo-44304: Ensure the sqlite3 destructor callback is always called with the GIL held (GH-26551) (GH_26552)
(cherry picked from commit 6e3b7cf3af3ed7758b2c2193c1d393feb8ab8f72)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index cf7fba6..072b07d 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -398,7 +398,9 @@ stmt_dealloc(pysqlite_Statement *self)
PyObject_ClearWeakRefs((PyObject*)self);
}
if (self->st) {
+ Py_BEGIN_ALLOW_THREADS
sqlite3_finalize(self->st);
+ Py_END_ALLOW_THREADS
self->st = 0;
}
tp->tp_clear((PyObject *)self);