File tree 1 file changed +9
-9
lines changed
1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -781,34 +781,34 @@ static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self)
781
781
static callback_context *
782
782
create_callback_context (pysqlite_state * state , PyObject * callable )
783
783
{
784
- PyGILState_STATE gstate = PyGILState_Ensure ();
785
784
callback_context * ctx = PyMem_Malloc (sizeof (callback_context ));
786
785
if (ctx != NULL ) {
787
786
ctx -> callable = Py_NewRef (callable );
788
787
ctx -> state = state ;
789
788
}
790
- PyGILState_Release (gstate );
791
789
return ctx ;
792
790
}
793
791
794
792
static void
795
793
free_callback_context (callback_context * ctx )
794
+ {
795
+ assert (ctx != NULL );
796
+ Py_DECREF (ctx -> callable );
797
+ PyMem_Free (ctx );
798
+ }
799
+
800
+ static void
801
+ _destructor (void * ctx )
796
802
{
797
803
if (ctx != NULL ) {
798
804
// This function may be called without the GIL held, so we need to
799
805
// ensure that we destroy 'ctx' with the GIL held.
800
806
PyGILState_STATE gstate = PyGILState_Ensure ();
801
- Py_DECREF (ctx -> callable );
802
- PyMem_Free (ctx );
807
+ free_callback_context ((callback_context * )ctx );
803
808
PyGILState_Release (gstate );
804
809
}
805
810
}
806
811
807
- static void _destructor (void * args )
808
- {
809
- free_callback_context ((callback_context * )args );
810
- }
811
-
812
812
/*[clinic input]
813
813
_sqlite3.Connection.create_function as pysqlite_connection_create_function
814
814
You can’t perform that action at this time.
0 commit comments