Index: Modules/_sqlite/connection.c =================================================================== --- Modules/_sqlite/connection.c (révision 68842) +++ Modules/_sqlite/connection.c (copie de travail) @@ -585,9 +585,11 @@ PyObject* py_func; PyObject* py_retval = NULL; +#ifdef WITH_THREAD PyGILState_STATE threadstate; threadstate = PyGILState_Ensure(); +#endif py_func = (PyObject*)sqlite3_user_data(context); @@ -609,7 +611,9 @@ _sqlite3_result_error(context, "user-defined function raised exception", -1); } +#ifdef WITH_THREAD PyGILState_Release(threadstate); +#endif } static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_value** params) @@ -620,9 +624,11 @@ PyObject** aggregate_instance; PyObject* stepmethod = NULL; +#ifdef WITH_THREAD PyGILState_STATE threadstate; threadstate = PyGILState_Ensure(); +#endif aggregate_class = (PyObject*)sqlite3_user_data(context); @@ -669,7 +675,9 @@ Py_XDECREF(stepmethod); Py_XDECREF(function_result); +#ifdef WITH_THREAD PyGILState_Release(threadstate); +#endif } void _pysqlite_final_callback(sqlite3_context* context) @@ -678,9 +686,11 @@ PyObject** aggregate_instance; PyObject* aggregate_class; +#ifdef WITH_THREAD PyGILState_STATE threadstate; threadstate = PyGILState_Ensure(); +#endif aggregate_class = (PyObject*)sqlite3_user_data(context); @@ -708,7 +718,9 @@ Py_XDECREF(*aggregate_instance); Py_XDECREF(function_result); +#ifdef WITH_THREAD PyGILState_Release(threadstate); +#endif } void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self) @@ -803,9 +815,11 @@ { PyObject *ret; int rc; +#ifdef WITH_THREAD PyGILState_STATE gilstate; gilstate = PyGILState_Ensure(); +#endif ret = PyObject_CallFunction((PyObject*)user_arg, "issss", action, arg1, arg2, dbname, access_attempt_source); if (!ret) { @@ -825,7 +839,9 @@ Py_DECREF(ret); } +#ifdef WITH_THREAD PyGILState_Release(gilstate); +#endif return rc; } @@ -833,9 +849,11 @@ { int rc; PyObject *ret; +#ifdef WITH_THREAD PyGILState_STATE gilstate; gilstate = PyGILState_Ensure(); +#endif ret = PyObject_CallFunction((PyObject*)user_arg, ""); if (!ret) { @@ -852,7 +870,9 @@ Py_DECREF(ret); } +#ifdef WITH_THREAD PyGILState_Release(gilstate); +#endif return rc; } @@ -1139,12 +1159,13 @@ PyObject* callback = (PyObject*)context; PyObject* string1 = 0; PyObject* string2 = 0; - PyGILState_STATE gilstate; - PyObject* retval = NULL; int result = 0; +#ifdef WITH_THREAD + PyGILState_STATE gilstate; gilstate = PyGILState_Ensure(); +#endif if (PyErr_Occurred()) { goto finally; @@ -1174,7 +1195,9 @@ Py_XDECREF(string2); Py_XDECREF(retval); +#ifdef WITH_THREAD PyGILState_Release(gilstate); +#endif return result; } Index: Modules/_sqlite/module.c =================================================================== --- Modules/_sqlite/module.c (révision 68842) +++ Modules/_sqlite/module.c (copie de travail) @@ -432,6 +432,7 @@ pysqlite_BaseTypeAdapted = 0; +#ifdef WITH_THREAD /* Original comment from _bsddb.c in the Python core. This is also still * needed nowadays for Python 2.3/2.4. * @@ -446,6 +447,7 @@ * (see pybsddb-users mailing list post on 2002-08-07) */ PyEval_InitThreads(); +#endif error: if (PyErr_Occurred())