@@ -654,7 +654,8 @@ _pysqlite_func_callback(sqlite3_context *context, int argc, sqlite3_value **argv
654
654
PyGILState_Release (threadstate );
655
655
}
656
656
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 )
658
659
{
659
660
PyGILState_STATE threadstate = PyGILState_Ensure ();
660
661
@@ -702,7 +703,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
702
703
}
703
704
704
705
static void
705
- _pysqlite_final_callback (sqlite3_context * context )
706
+ final_callback (sqlite3_context * context )
706
707
{
707
708
PyGILState_STATE threadstate = PyGILState_Ensure ();
708
709
@@ -800,7 +801,7 @@ free_callback_context(callback_context *ctx)
800
801
}
801
802
802
803
static void
803
- _destructor (void * ctx )
804
+ destructor_callback (void * ctx )
804
805
{
805
806
if (ctx != NULL ) {
806
807
// This function may be called without the GIL held, so we need to
@@ -858,7 +859,7 @@ pysqlite_connection_create_function_impl(pysqlite_Connection *self,
858
859
_pysqlite_func_callback ,
859
860
NULL ,
860
861
NULL ,
861
- & _destructor ); // will decref func
862
+ & destructor_callback ); // will decref func
862
863
863
864
if (rc != SQLITE_OK ) {
864
865
/* Workaround for SQLite bug: no error code or string is available here */
@@ -897,9 +898,9 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
897
898
}
898
899
rc = sqlite3_create_function_v2 (self -> db , name , n_arg , SQLITE_UTF8 , ctx ,
899
900
0 ,
900
- & _pysqlite_step_callback ,
901
- & _pysqlite_final_callback ,
902
- & _destructor ); // will decref func
901
+ & step_callback ,
902
+ & final_callback ,
903
+ & destructor_callback ); // will decref func
903
904
if (rc != SQLITE_OK ) {
904
905
/* Workaround for SQLite bug: no error code or string is available here */
905
906
PyErr_SetString (self -> OperationalError , "Error creating aggregate" );
@@ -908,14 +909,18 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
908
909
Py_RETURN_NONE ;
909
910
}
910
911
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 )
912
916
{
913
917
PyGILState_STATE gilstate = PyGILState_Ensure ();
914
918
915
919
PyObject * ret ;
916
920
int rc ;
917
921
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 );
919
924
920
925
if (ret == NULL ) {
921
926
pysqlite_state * state = pysqlite_get_state (NULL );
@@ -952,13 +957,14 @@ static int _authorizer_callback(void* user_arg, int action, const char* arg1, co
952
957
return rc ;
953
958
}
954
959
955
- static int _progress_handler (void * user_arg )
960
+ static int
961
+ progress_callback (void * ctx )
956
962
{
957
963
PyGILState_STATE gilstate = PyGILState_Ensure ();
958
964
959
965
int rc ;
960
966
PyObject * ret ;
961
- ret = _PyObject_CallNoArg ((PyObject * )user_arg );
967
+ ret = _PyObject_CallNoArg ((PyObject * )ctx );
962
968
963
969
if (!ret ) {
964
970
/* abort query if error occurred */
@@ -989,9 +995,12 @@ static int _progress_handler(void* user_arg)
989
995
* may change in future releases. Callback implementations should return zero
990
996
* to ensure future compatibility.
991
997
*/
992
- 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 )
993
1001
#else
994
- static void _trace_callback (void * user_arg , const char * statement_string )
1002
+ static void
1003
+ trace_callback (void * ctx , const char * statement_string )
995
1004
#endif
996
1005
{
997
1006
#ifdef HAVE_TRACE_V2
@@ -1007,7 +1016,7 @@ static void _trace_callback(void* user_arg, const char* statement_string)
1007
1016
py_statement = PyUnicode_DecodeUTF8 (statement_string ,
1008
1017
strlen (statement_string ), "replace" );
1009
1018
if (py_statement ) {
1010
- ret = PyObject_CallOneArg ((PyObject * )user_arg , py_statement );
1019
+ ret = PyObject_CallOneArg ((PyObject * )ctx , py_statement );
1011
1020
Py_DECREF (py_statement );
1012
1021
}
1013
1022
@@ -1032,29 +1041,29 @@ static void _trace_callback(void* user_arg, const char* statement_string)
1032
1041
/*[clinic input]
1033
1042
_sqlite3.Connection.set_authorizer as pysqlite_connection_set_authorizer
1034
1043
1035
- authorizer_callback as authorizer_cb : object
1044
+ authorizer_callback as callable : object
1036
1045
1037
1046
Sets authorizer callback. Non-standard.
1038
1047
[clinic start generated code]*/
1039
1048
1040
1049
static PyObject *
1041
1050
pysqlite_connection_set_authorizer_impl (pysqlite_Connection * self ,
1042
- PyObject * authorizer_cb )
1043
- /*[clinic end generated code: output=f18ba575d788b35c input=df079724c020d2f2 ]*/
1051
+ PyObject * callable )
1052
+ /*[clinic end generated code: output=c193601e9e8a5116 input=ec104f130b82050b ]*/
1044
1053
{
1045
1054
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
1046
1055
return NULL ;
1047
1056
}
1048
1057
1049
1058
int rc ;
1050
- if (authorizer_cb == Py_None ) {
1059
+ if (callable == Py_None ) {
1051
1060
rc = sqlite3_set_authorizer (self -> db , NULL , NULL );
1052
1061
Py_XSETREF (self -> function_pinboard_authorizer_cb , NULL );
1053
1062
}
1054
1063
else {
1055
- Py_INCREF (authorizer_cb );
1056
- Py_XSETREF (self -> function_pinboard_authorizer_cb , authorizer_cb );
1057
- 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 );
1058
1067
}
1059
1068
if (rc != SQLITE_OK ) {
1060
1069
PyErr_SetString (self -> OperationalError ,
@@ -1068,38 +1077,37 @@ pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
1068
1077
/*[clinic input]
1069
1078
_sqlite3.Connection.set_progress_handler as pysqlite_connection_set_progress_handler
1070
1079
1071
- progress_handler: object
1080
+ progress_handler as callable : object
1072
1081
n: int
1073
1082
1074
1083
Sets progress handler callback. Non-standard.
1075
1084
[clinic start generated code]*/
1076
1085
1077
1086
static PyObject *
1078
1087
pysqlite_connection_set_progress_handler_impl (pysqlite_Connection * self ,
1079
- PyObject * progress_handler ,
1080
- int n )
1081
- /*[clinic end generated code: output=35a7c10364cb1b04 input=857696c25f964c64]*/
1088
+ PyObject * callable , int n )
1089
+ /*[clinic end generated code: output=ba14008a483d7a53 input=3cf56d045f130a84]*/
1082
1090
{
1083
1091
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
1084
1092
return NULL ;
1085
1093
}
1086
1094
1087
- if (progress_handler == Py_None ) {
1095
+ if (callable == Py_None ) {
1088
1096
/* None clears the progress handler previously set */
1089
1097
sqlite3_progress_handler (self -> db , 0 , 0 , (void * )0 );
1090
1098
Py_XSETREF (self -> function_pinboard_progress_handler , NULL );
1091
1099
} else {
1092
- sqlite3_progress_handler (self -> db , n , _progress_handler , progress_handler );
1093
- Py_INCREF (progress_handler );
1094
- 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 );
1095
1103
}
1096
1104
Py_RETURN_NONE ;
1097
1105
}
1098
1106
1099
1107
/*[clinic input]
1100
1108
_sqlite3.Connection.set_trace_callback as pysqlite_connection_set_trace_callback
1101
1109
1102
- trace_callback: object
1110
+ trace_callback as callable : object
1103
1111
1104
1112
Sets a trace callback called for each SQL statement (passed as unicode).
1105
1113
@@ -1108,14 +1116,14 @@ Non-standard.
1108
1116
1109
1117
static PyObject *
1110
1118
pysqlite_connection_set_trace_callback_impl (pysqlite_Connection * self ,
1111
- PyObject * trace_callback )
1112
- /*[clinic end generated code: output=fb0e307b9924d454 input=56d60fd38d763679 ]*/
1119
+ PyObject * callable )
1120
+ /*[clinic end generated code: output=c9fd551e359165d3 input=d76eabbb633057bc ]*/
1113
1121
{
1114
1122
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
1115
1123
return NULL ;
1116
1124
}
1117
1125
1118
- if (trace_callback == Py_None ) {
1126
+ if (callable == Py_None ) {
1119
1127
/*
1120
1128
* None clears the trace callback previously set
1121
1129
*
@@ -1131,12 +1139,12 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
1131
1139
Py_XSETREF (self -> function_pinboard_trace_callback , NULL );
1132
1140
} else {
1133
1141
#ifdef HAVE_TRACE_V2
1134
- sqlite3_trace_v2 (self -> db , SQLITE_TRACE_STMT , _trace_callback , trace_callback );
1142
+ sqlite3_trace_v2 (self -> db , SQLITE_TRACE_STMT , trace_callback , callable );
1135
1143
#else
1136
- sqlite3_trace (self -> db , _trace_callback , trace_callback );
1144
+ sqlite3_trace (self -> db , trace_callback , callable );
1137
1145
#endif
1138
- Py_INCREF (trace_callback );
1139
- Py_XSETREF (self -> function_pinboard_trace_callback , trace_callback );
1146
+ Py_INCREF (callable );
1147
+ Py_XSETREF (self -> function_pinboard_trace_callback , callable );
1140
1148
}
1141
1149
1142
1150
Py_RETURN_NONE ;
@@ -1726,7 +1734,7 @@ pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
1726
1734
}
1727
1735
rc = sqlite3_create_collation_v2 (self -> db , name , flags , ctx ,
1728
1736
& pysqlite_collation_callback ,
1729
- & _destructor );
1737
+ & destructor_callback );
1730
1738
}
1731
1739
1732
1740
if (rc != SQLITE_OK ) {
0 commit comments