@@ -188,7 +188,7 @@ connection_exec_stmt(pysqlite_Connection *self, const char *sql)
188188 Py_END_ALLOW_THREADS
189189
190190 if (rc != SQLITE_OK ) {
191- ( void ) _pysqlite_seterror (self -> state , self -> db );
191+ set_error_from_db (self -> state , self -> db );
192192 return -1 ;
193193 }
194194 return 0 ;
@@ -274,7 +274,7 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
274274
275275 pysqlite_state * state = pysqlite_get_state_by_type (Py_TYPE (self ));
276276 if (rc != SQLITE_OK ) {
277- _pysqlite_seterror (state , db );
277+ set_error_from_db (state , db );
278278 goto error ;
279279 }
280280
@@ -607,11 +607,11 @@ blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
607607 Py_END_ALLOW_THREADS
608608
609609 if (rc == SQLITE_MISUSE ) {
610- PyErr_Format (self -> state -> InterfaceError , sqlite3_errstr ( rc ) );
610+ set_error_from_code (self -> state , rc );
611611 return NULL ;
612612 }
613613 else if (rc != SQLITE_OK ) {
614- _pysqlite_seterror (self -> state , self -> db );
614+ set_error_from_db (self -> state , self -> db );
615615 return NULL ;
616616 }
617617
@@ -1352,9 +1352,9 @@ create_window_function_impl(pysqlite_Connection *self, PyTypeObject *cls,
13521352 }
13531353
13541354 if (rc != SQLITE_OK ) {
1355- // Errors are not set on the database connection, so we cannot
1356- // use _pysqlite_seterror().
1357- PyErr_SetString (self -> ProgrammingError , sqlite3_errstr ( rc ) );
1355+ /* Errors are not set on the database connection; use result code
1356+ * instead. */
1357+ set_error_from_code (self -> state , rc );
13581358 return NULL ;
13591359 }
13601360 Py_RETURN_NONE ;
@@ -2112,7 +2112,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
21122112 Py_END_ALLOW_THREADS
21132113
21142114 if (bck_handle == NULL) {
2115- _pysqlite_seterror (self -> state , bck_conn );
2115+ set_error_from_db (self -> state , bck_conn );
21162116 return NULL ;
21172117 }
21182118
@@ -2150,7 +2150,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
21502150 Py_END_ALLOW_THREADS
21512151
21522152 if (rc != SQLITE_OK ) {
2153- _pysqlite_seterror (self -> state , bck_conn );
2153+ set_error_from_db (self -> state , bck_conn );
21542154 return NULL ;
21552155 }
21562156
@@ -2208,7 +2208,7 @@ pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
22082208 if (callable != Py_None ) {
22092209 free_callback_context (ctx );
22102210 }
2211- _pysqlite_seterror (self -> state , self -> db );
2211+ set_error_from_db (self -> state , self -> db );
22122212 return NULL ;
22132213 }
22142214
@@ -2326,7 +2326,7 @@ deserialize_impl(pysqlite_Connection *self, Py_buffer *data,
23262326 Py_END_ALLOW_THREADS
23272327
23282328 if (rc != SQLITE_OK ) {
2329- ( void ) _pysqlite_seterror (self -> state , self -> db );
2329+ set_error_from_db (self -> state , self -> db );
23302330 return NULL ;
23312331 }
23322332 Py_RETURN_NONE ;
@@ -2521,7 +2521,7 @@ setconfig_impl(pysqlite_Connection *self, int op, int enable)
25212521 int actual ;
25222522 int rc = sqlite3_db_config (self -> db , op , enable , & actual );
25232523 if (rc != SQLITE_OK ) {
2524- ( void ) _pysqlite_seterror (self -> state , self -> db );
2524+ set_error_from_db (self -> state , self -> db );
25252525 return NULL ;
25262526 }
25272527 if (enable != actual ) {
@@ -2556,7 +2556,7 @@ getconfig_impl(pysqlite_Connection *self, int op)
25562556 int current ;
25572557 int rc = sqlite3_db_config (self -> db , op , -1 , & current );
25582558 if (rc != SQLITE_OK ) {
2559- ( void ) _pysqlite_seterror (self -> state , self -> db );
2559+ set_error_from_db (self -> state , self -> db );
25602560 return -1 ;
25612561 }
25622562 return current ;
0 commit comments