mirror of https://github.com/python/cpython
bpo-44304: Ensure the sqlite3 destructor callback is always called with the GIL held (GH-26551)
This commit is contained in:
parent
fa106a685c
commit
6e3b7cf3af
|
@ -825,7 +825,12 @@ static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self)
|
|||
|
||||
static void _destructor(void* args)
|
||||
{
|
||||
// This function may be called without the GIL held, so we need to ensure
|
||||
// that we destroy 'args' with the GIL
|
||||
PyGILState_STATE gstate;
|
||||
gstate = PyGILState_Ensure();
|
||||
Py_DECREF((PyObject*)args);
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
|
|
@ -404,7 +404,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);
|
||||
|
|
Loading…
Reference in New Issue