gh-129928: Rework sqlite3 error helpers (#129929)

Add a helper for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

- rename _pysqlite_seterror() as set_error_from_db()
- introduce set_error_from_code()
This commit is contained in:
Erlend E. Aasland 2025-02-11 08:49:25 +01:00 committed by GitHub
parent 3a2e7aacf6
commit 3b366a4a4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 41 additions and 30 deletions

View file

@ -30,9 +30,9 @@
/**
* Checks the SQLite error code and sets the appropriate DB-API exception.
* Returns the error code (0 means no error occurred).
*/
int _pysqlite_seterror(pysqlite_state *state, sqlite3 *db);
void set_error_from_db(pysqlite_state *state, sqlite3 *db);
void set_error_from_code(pysqlite_state *state, int code);
sqlite_int64 _pysqlite_long_as_int64(PyObject * value);