gh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572)

* Map SQLITE_MISUSE to sqlite3.InterfaceError

SQLITE_MISUSE implies misuse of the SQLite C API, which, if it happens,
is _not_ a user error; it is an sqlite3 extension module error.

* Raise better errors when binding parameters fail.

Instead of always raising InterfaceError, guessing what went wrong,
raise accurate exceptions with more accurate error messages.
This commit is contained in:
Erlend Egeberg Aasland 2022-05-04 07:16:01 -06:00 committed by GitHub
parent d716a0dfe2
commit 090819ec5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 20 deletions

View file

@ -59,7 +59,6 @@ get_exception_class(pysqlite_state *state, int errorcode)
case SQLITE_MISMATCH:
return state->IntegrityError;
case SQLITE_MISUSE:
return state->ProgrammingError;
case SQLITE_RANGE:
return state->InterfaceError;
default: