mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-43249: sqlite3_column_bytes() must follow sqlite_column_blob() (GH-24562)
This commit is contained in:
parent
7be00ee64a
commit
47feb1feb2
1 changed files with 14 additions and 4 deletions
|
@ -278,9 +278,15 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
||||||
converter = Py_None;
|
converter = Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note, sqlite3_column_bytes() must come after sqlite3_column_blob()
|
||||||
|
* or sqlite3_column_text().
|
||||||
|
*
|
||||||
|
* See https://sqlite.org/c3ref/column_blob.html for details.
|
||||||
|
*/
|
||||||
if (converter != Py_None) {
|
if (converter != Py_None) {
|
||||||
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
|
||||||
val_str = (const char*)sqlite3_column_blob(self->statement->st, i);
|
val_str = (const char*)sqlite3_column_blob(self->statement->st, i);
|
||||||
|
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
||||||
if (!val_str) {
|
if (!val_str) {
|
||||||
converted = Py_NewRef(Py_None);
|
converted = Py_NewRef(Py_None);
|
||||||
} else {
|
} else {
|
||||||
|
@ -330,9 +336,13 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* coltype == SQLITE_BLOB */
|
/* coltype == SQLITE_BLOB */
|
||||||
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
const char *blob = sqlite3_column_blob(self->statement->st, i);
|
||||||
converted = PyBytes_FromStringAndSize(
|
if (!blob) {
|
||||||
sqlite3_column_blob(self->statement->st, i), nbytes);
|
converted = Py_NewRef(Py_None);
|
||||||
|
} else {
|
||||||
|
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
||||||
|
converted = PyBytes_FromStringAndSize(blob, nbytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue