@@ -654,7 +654,8 @@ _pysqlite_func_callback(sqlite3_context *context, int argc, sqlite3_value **argv
654654 PyGILState_Release (threadstate );
655655}
656656
657- static void _pysqlite_step_callback (sqlite3_context * context , int argc , sqlite3_value * * params )
657+ static void
658+ step_callback (sqlite3_context * context , int argc , sqlite3_value * * params )
658659{
659660 PyGILState_STATE threadstate = PyGILState_Ensure ();
660661
@@ -702,7 +703,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
702703}
703704
704705static void
705- _pysqlite_final_callback (sqlite3_context * context )
706+ final_callback (sqlite3_context * context )
706707{
707708 PyGILState_STATE threadstate = PyGILState_Ensure ();
708709
@@ -897,8 +898,8 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
897898 }
898899 rc = sqlite3_create_function_v2 (self -> db , name , n_arg , SQLITE_UTF8 , ctx ,
899900 0 ,
900- & _pysqlite_step_callback ,
901- & _pysqlite_final_callback ,
901+ & step_callback ,
902+ & final_callback ,
902903 & destructor_callback ); // will decref func
903904 if (rc != SQLITE_OK ) {
904905 /* Workaround for SQLite bug: no error code or string is available here */
@@ -908,14 +909,18 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
908909 Py_RETURN_NONE ;
909910}
910911
911- static int _authorizer_callback (void * user_arg , int action , const char * arg1 , const char * arg2 , const char * dbname , const char * access_attempt_source )
912+ static int
913+ authorizer_callback (void * ctx , int action , const char * arg1 ,
914+ const char * arg2 , const char * dbname ,
915+ const char * access_attempt_source )
912916{
913917 PyGILState_STATE gilstate = PyGILState_Ensure ();
914918
915919 PyObject * ret ;
916920 int rc ;
917921
918- ret = PyObject_CallFunction ((PyObject * )user_arg , "issss" , action , arg1 , arg2 , dbname , access_attempt_source );
922+ ret = PyObject_CallFunction ((PyObject * )ctx , "issss" , action , arg1 , arg2 ,
923+ dbname , access_attempt_source );
919924
920925 if (ret == NULL ) {
921926 pysqlite_state * state = pysqlite_get_state (NULL );
@@ -953,13 +958,13 @@ static int _authorizer_callback(void* user_arg, int action, const char* arg1, co
953958}
954959
955960static int
956- progress_callback (void * user_arg )
961+ progress_callback (void * ctx )
957962{
958963 PyGILState_STATE gilstate = PyGILState_Ensure ();
959964
960965 int rc ;
961966 PyObject * ret ;
962- ret = _PyObject_CallNoArg ((PyObject * )user_arg );
967+ ret = _PyObject_CallNoArg ((PyObject * )ctx );
963968
964969 if (!ret ) {
965970 /* abort query if error occurred */
@@ -990,9 +995,12 @@ progress_callback(void *user_arg)
990995 * may change in future releases. Callback implementations should return zero
991996 * to ensure future compatibility.
992997 */
993- static int _trace_callback (unsigned int type , void * user_arg , void * prepared_statement , void * statement_string )
998+ static int
999+ trace_callback (unsigned int type , void * ctx , void * prepared_statement ,
1000+ void * statement_string )
9941001#else
995- static void _trace_callback (void * user_arg , const char * statement_string )
1002+ static void
1003+ trace_callback (void * ctx , const char * statement_string )
9961004#endif
9971005{
9981006#ifdef HAVE_TRACE_V2
@@ -1008,7 +1016,7 @@ static void _trace_callback(void* user_arg, const char* statement_string)
10081016 py_statement = PyUnicode_DecodeUTF8 (statement_string ,
10091017 strlen (statement_string ), "replace" );
10101018 if (py_statement ) {
1011- ret = PyObject_CallOneArg ((PyObject * )user_arg , py_statement );
1019+ ret = PyObject_CallOneArg ((PyObject * )ctx , py_statement );
10121020 Py_DECREF (py_statement );
10131021 }
10141022
@@ -1033,29 +1041,29 @@ static void _trace_callback(void* user_arg, const char* statement_string)
10331041/*[clinic input]
10341042_sqlite3.Connection.set_authorizer as pysqlite_connection_set_authorizer
10351043
1036- authorizer_callback as authorizer_cb : object
1044+ authorizer_callback as callable : object
10371045
10381046Sets authorizer callback. Non-standard.
10391047[clinic start generated code]*/
10401048
10411049static PyObject *
10421050pysqlite_connection_set_authorizer_impl (pysqlite_Connection * self ,
1043- PyObject * authorizer_cb )
1044- /*[clinic end generated code: output=f18ba575d788b35c input=df079724c020d2f2 ]*/
1051+ PyObject * callable )
1052+ /*[clinic end generated code: output=c193601e9e8a5116 input=ec104f130b82050b ]*/
10451053{
10461054 if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
10471055 return NULL ;
10481056 }
10491057
10501058 int rc ;
1051- if (authorizer_cb == Py_None ) {
1059+ if (callable == Py_None ) {
10521060 rc = sqlite3_set_authorizer (self -> db , NULL , NULL );
10531061 Py_XSETREF (self -> function_pinboard_authorizer_cb , NULL );
10541062 }
10551063 else {
1056- Py_INCREF (authorizer_cb );
1057- Py_XSETREF (self -> function_pinboard_authorizer_cb , authorizer_cb );
1058- rc = sqlite3_set_authorizer (self -> db , _authorizer_callback , authorizer_cb );
1064+ Py_INCREF (callable );
1065+ Py_XSETREF (self -> function_pinboard_authorizer_cb , callable );
1066+ rc = sqlite3_set_authorizer (self -> db , authorizer_callback , callable );
10591067 }
10601068 if (rc != SQLITE_OK ) {
10611069 PyErr_SetString (self -> OperationalError ,
@@ -1069,38 +1077,37 @@ pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
10691077/*[clinic input]
10701078_sqlite3.Connection.set_progress_handler as pysqlite_connection_set_progress_handler
10711079
1072- progress_handler: object
1080+ progress_handler as callable : object
10731081 n: int
10741082
10751083Sets progress handler callback. Non-standard.
10761084[clinic start generated code]*/
10771085
10781086static PyObject *
10791087pysqlite_connection_set_progress_handler_impl (pysqlite_Connection * self ,
1080- PyObject * progress_handler ,
1081- int n )
1082- /*[clinic end generated code: output=35a7c10364cb1b04 input=857696c25f964c64]*/
1088+ PyObject * callable , int n )
1089+ /*[clinic end generated code: output=ba14008a483d7a53 input=3cf56d045f130a84]*/
10831090{
10841091 if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
10851092 return NULL ;
10861093 }
10871094
1088- if (progress_handler == Py_None ) {
1095+ if (callable == Py_None ) {
10891096 /* None clears the progress handler previously set */
10901097 sqlite3_progress_handler (self -> db , 0 , 0 , (void * )0 );
10911098 Py_XSETREF (self -> function_pinboard_progress_handler , NULL );
10921099 } else {
1093- sqlite3_progress_handler (self -> db , n , progress_callback , progress_handler );
1094- Py_INCREF (progress_handler );
1095- Py_XSETREF (self -> function_pinboard_progress_handler , progress_handler );
1100+ sqlite3_progress_handler (self -> db , n , progress_callback , callable );
1101+ Py_INCREF (callable );
1102+ Py_XSETREF (self -> function_pinboard_progress_handler , callable );
10961103 }
10971104 Py_RETURN_NONE ;
10981105}
10991106
11001107/*[clinic input]
11011108_sqlite3.Connection.set_trace_callback as pysqlite_connection_set_trace_callback
11021109
1103- trace_callback: object
1110+ trace_callback as callable : object
11041111
11051112Sets a trace callback called for each SQL statement (passed as unicode).
11061113
@@ -1109,14 +1116,14 @@ Non-standard.
11091116
11101117static PyObject *
11111118pysqlite_connection_set_trace_callback_impl (pysqlite_Connection * self ,
1112- PyObject * trace_callback )
1113- /*[clinic end generated code: output=fb0e307b9924d454 input=56d60fd38d763679 ]*/
1119+ PyObject * callable )
1120+ /*[clinic end generated code: output=c9fd551e359165d3 input=d76eabbb633057bc ]*/
11141121{
11151122 if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
11161123 return NULL ;
11171124 }
11181125
1119- if (trace_callback == Py_None ) {
1126+ if (callable == Py_None ) {
11201127 /*
11211128 * None clears the trace callback previously set
11221129 *
@@ -1132,12 +1139,12 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
11321139 Py_XSETREF (self -> function_pinboard_trace_callback , NULL );
11331140 } else {
11341141#ifdef HAVE_TRACE_V2
1135- sqlite3_trace_v2 (self -> db , SQLITE_TRACE_STMT , _trace_callback , trace_callback );
1142+ sqlite3_trace_v2 (self -> db , SQLITE_TRACE_STMT , trace_callback , callable );
11361143#else
1137- sqlite3_trace (self -> db , _trace_callback , trace_callback );
1144+ sqlite3_trace (self -> db , trace_callback , callable );
11381145#endif
1139- Py_INCREF (trace_callback );
1140- Py_XSETREF (self -> function_pinboard_trace_callback , trace_callback );
1146+ Py_INCREF (callable );
1147+ Py_XSETREF (self -> function_pinboard_trace_callback , callable );
11411148 }
11421149
11431150 Py_RETURN_NONE ;
0 commit comments