mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-42064: Move sqlite3
exceptions to global state, part 1 of 2 (GH-26745)
Also adds a test to verify the (borrowed) exceptions in `sqlite3.Connection`.
This commit is contained in:
parent
489699ca05
commit
a50e28377b
8 changed files with 66 additions and 48 deletions
|
@ -43,6 +43,7 @@ pysqlite_step(sqlite3_stmt *statement)
|
|||
int
|
||||
_pysqlite_seterror(sqlite3 *db)
|
||||
{
|
||||
pysqlite_state *state = pysqlite_get_state(NULL);
|
||||
int errorcode = sqlite3_errcode(db);
|
||||
|
||||
switch (errorcode)
|
||||
|
@ -52,7 +53,7 @@ _pysqlite_seterror(sqlite3 *db)
|
|||
break;
|
||||
case SQLITE_INTERNAL:
|
||||
case SQLITE_NOTFOUND:
|
||||
PyErr_SetString(pysqlite_InternalError, sqlite3_errmsg(db));
|
||||
PyErr_SetString(state->InternalError, sqlite3_errmsg(db));
|
||||
break;
|
||||
case SQLITE_NOMEM:
|
||||
(void)PyErr_NoMemory();
|
||||
|
@ -73,7 +74,7 @@ _pysqlite_seterror(sqlite3 *db)
|
|||
PyErr_SetString(pysqlite_OperationalError, sqlite3_errmsg(db));
|
||||
break;
|
||||
case SQLITE_CORRUPT:
|
||||
PyErr_SetString(pysqlite_DatabaseError, sqlite3_errmsg(db));
|
||||
PyErr_SetString(state->DatabaseError, sqlite3_errmsg(db));
|
||||
break;
|
||||
case SQLITE_TOOBIG:
|
||||
PyErr_SetString(pysqlite_DataError, sqlite3_errmsg(db));
|
||||
|
@ -86,7 +87,7 @@ _pysqlite_seterror(sqlite3 *db)
|
|||
PyErr_SetString(pysqlite_ProgrammingError, sqlite3_errmsg(db));
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(pysqlite_DatabaseError, sqlite3_errmsg(db));
|
||||
PyErr_SetString(state->DatabaseError, sqlite3_errmsg(db));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue