Skip to content

Commit c06a4ff

Browse files
author
Erlend Egeberg Aasland
authored
gh-69093: improve sqlite3.Connection.blobopen() error handling (GH-91571)
Unless sqlite3_blob_open() returns SQLITE_MISUSE, the error code and message are available on the connection object. This means we have to handle SQLITE_MISUSE error messages explicitly.
1 parent 1b34b56 commit c06a4ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/_sqlite/connection.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,11 @@ blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
475475
rc = sqlite3_blob_open(self->db, name, table, col, row, !readonly, &blob);
476476
Py_END_ALLOW_THREADS
477477

478-
if (rc != SQLITE_OK) {
478+
if (rc == SQLITE_MISUSE) {
479+
PyErr_Format(self->state->InterfaceError, sqlite3_errstr(rc));
480+
return NULL;
481+
}
482+
else if (rc != SQLITE_OK) {
479483
_pysqlite_seterror(self->state, self->db);
480484
return NULL;
481485
}

0 commit comments

Comments
 (0)