3333#define ACTION_FINALIZE 1
3434#define ACTION_RESET 2
3535
36- #if SQLITE_VERSION_NUMBER >= 3003008
37- #ifndef SQLITE_OMIT_LOAD_EXTENSION
38- #define HAVE_LOAD_EXTENSION
39- #endif
40- #endif
41-
42- #if SQLITE_VERSION_NUMBER >= 3006011
43- #define HAVE_BACKUP_API
44- #endif
45-
4636#if SQLITE_VERSION_NUMBER >= 3014000
4737#define HAVE_TRACE_V2
4838#endif
@@ -61,18 +51,6 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
6151static void _pysqlite_drop_unused_cursor_references (pysqlite_Connection * self );
6252
6353
64- static void _sqlite3_result_error (sqlite3_context * ctx , const char * errmsg , int len )
65- {
66- /* in older SQLite versions, calling sqlite3_result_error in callbacks
67- * triggers a bug in SQLite that leads either to irritating results or
68- * segfaults, depending on the SQLite version */
69- #if SQLITE_VERSION_NUMBER >= 3003003
70- sqlite3_result_error (ctx , errmsg , len );
71- #else
72- PyErr_SetString (pysqlite_OperationalError , errmsg );
73- #endif
74- }
75-
7654int pysqlite_connection_init (pysqlite_Connection * self , PyObject * args , PyObject * kwargs )
7755{
7856 static char * kwlist [] = {
@@ -182,10 +160,6 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
182160 self -> timeout = timeout ;
183161 (void )sqlite3_busy_timeout (self -> db , (int )(timeout * 1000 ));
184162 self -> thread_ident = PyThread_get_thread_ident ();
185- if (!check_same_thread && sqlite3_libversion_number () < 3003001 ) {
186- PyErr_SetString (pysqlite_NotSupportedError , "shared connections not available" );
187- return -1 ;
188- }
189163 self -> check_same_thread = check_same_thread ;
190164
191165 self -> function_pinboard_trace_callback = NULL ;
@@ -620,7 +594,7 @@ void _pysqlite_func_callback(sqlite3_context* context, int argc, sqlite3_value**
620594 } else {
621595 PyErr_Clear ();
622596 }
623- _sqlite3_result_error (context , "user-defined function raised exception" , -1 );
597+ sqlite3_result_error (context , "user-defined function raised exception" , -1 );
624598 }
625599
626600 PyGILState_Release (threadstate );
@@ -652,7 +626,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
652626 } else {
653627 PyErr_Clear ();
654628 }
655- _sqlite3_result_error (context , "user-defined aggregate's '__init__' method raised error" , -1 );
629+ sqlite3_result_error (context , "user-defined aggregate's '__init__' method raised error" , -1 );
656630 goto error ;
657631 }
658632 }
@@ -676,7 +650,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
676650 } else {
677651 PyErr_Clear ();
678652 }
679- _sqlite3_result_error (context , "user-defined aggregate's 'step' method raised error" , -1 );
653+ sqlite3_result_error (context , "user-defined aggregate's 'step' method raised error" , -1 );
680654 }
681655
682656error :
@@ -693,7 +667,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
693667 _Py_IDENTIFIER (finalize );
694668 int ok ;
695669 PyObject * exception , * value , * tb ;
696- int restore ;
697670
698671 PyGILState_STATE threadstate ;
699672
@@ -709,7 +682,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
709682
710683 /* Keep the exception (if any) of the last call to step() */
711684 PyErr_Fetch (& exception , & value , & tb );
712- restore = 1 ;
713685
714686 function_result = _PyObject_CallMethodIdNoArgs (* aggregate_instance , & PyId_finalize );
715687
@@ -726,19 +698,12 @@ void _pysqlite_final_callback(sqlite3_context* context)
726698 } else {
727699 PyErr_Clear ();
728700 }
729- _sqlite3_result_error (context , "user-defined aggregate's 'finalize' method raised error" , -1 );
730- #if SQLITE_VERSION_NUMBER < 3003003
731- /* with old SQLite versions, _sqlite3_result_error() sets a new Python
732- exception, so don't restore the previous exception */
733- restore = 0 ;
734- #endif
701+ sqlite3_result_error (context , "user-defined aggregate's 'finalize' method raised error" , -1 );
735702 }
736703
737- if (restore ) {
738- /* Restore the exception (if any) of the last call to step(),
739- but clear also the current exception if finalize() failed */
740- PyErr_Restore (exception , value , tb );
741- }
704+ /* Restore the exception (if any) of the last call to step(),
705+ but clear also the current exception if finalize() failed */
706+ PyErr_Restore (exception , value , tb );
742707
743708error :
744709 PyGILState_Release (threadstate );
@@ -1110,7 +1075,7 @@ static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* sel
11101075 Py_RETURN_NONE ;
11111076}
11121077
1113- #ifdef HAVE_LOAD_EXTENSION
1078+ #ifndef SQLITE_OMIT_LOAD_EXTENSION
11141079static PyObject * pysqlite_enable_load_extension (pysqlite_Connection * self , PyObject * args )
11151080{
11161081 int rc ;
@@ -1513,7 +1478,6 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args)
15131478 return retval ;
15141479}
15151480
1516- #ifdef HAVE_BACKUP_API
15171481static PyObject *
15181482pysqlite_connection_backup (pysqlite_Connection * self , PyObject * args , PyObject * kwds )
15191483{
@@ -1664,7 +1628,6 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
16641628 return NULL ;
16651629 }
16661630}
1667- #endif
16681631
16691632static PyObject *
16701633pysqlite_connection_create_collation (pysqlite_Connection * self , PyObject * args )
@@ -1816,7 +1779,7 @@ static PyMethodDef connection_methods[] = {
18161779 PyDoc_STR ("Creates a new aggregate. Non-standard." )},
18171780 {"set_authorizer" , (PyCFunction )(void (* )(void ))pysqlite_connection_set_authorizer , METH_VARARGS |METH_KEYWORDS ,
18181781 PyDoc_STR ("Sets authorizer callback. Non-standard." )},
1819- #ifdef HAVE_LOAD_EXTENSION
1782+ #ifndef SQLITE_OMIT_LOAD_EXTENSION
18201783 {"enable_load_extension" , (PyCFunction )pysqlite_enable_load_extension , METH_VARARGS ,
18211784 PyDoc_STR ("Enable dynamic loading of SQLite extension modules. Non-standard." )},
18221785 {"load_extension" , (PyCFunction )pysqlite_load_extension , METH_VARARGS ,
@@ -1838,10 +1801,8 @@ static PyMethodDef connection_methods[] = {
18381801 PyDoc_STR ("Abort any pending database operation. Non-standard." )},
18391802 {"iterdump" , (PyCFunction )pysqlite_connection_iterdump , METH_NOARGS ,
18401803 PyDoc_STR ("Returns iterator to the dump of the database in an SQL text format. Non-standard." )},
1841- #ifdef HAVE_BACKUP_API
18421804 {"backup" , (PyCFunction )(void (* )(void ))pysqlite_connection_backup , METH_VARARGS | METH_KEYWORDS ,
18431805 PyDoc_STR ("Makes a backup of the database. Non-standard." )},
1844- #endif
18451806 {"__enter__" , (PyCFunction )pysqlite_connection_enter , METH_NOARGS ,
18461807 PyDoc_STR ("For context manager. Non-standard." )},
18471808 {"__exit__" , (PyCFunction )pysqlite_connection_exit , METH_VARARGS ,
0 commit comments