mirror of https://github.com/python/cpython
bpo-43368: Fix fetching empty bytes in sqlite3 (GH-24706)
Regression introduced in 47feb1feb2
.
This commit is contained in:
parent
09605ad726
commit
3b4b2cf418
|
@ -409,6 +409,10 @@ class RegressionTests(unittest.TestCase):
|
|||
self.con.execute("select 1") # trigger seg fault
|
||||
method(None)
|
||||
|
||||
def test_return_empty_bytestring(self):
|
||||
cur = self.con.execute("select X''")
|
||||
val = cur.fetchone()[0]
|
||||
self.assertEqual(val, b'')
|
||||
|
||||
|
||||
def suite():
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix a regression introduced in GH-24562, where an empty bytestring was fetched
|
||||
as ``None`` instead of ``b''`` in :mod:`sqlite3`. Patch by Mariusz Felisiak.
|
|
@ -333,12 +333,8 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
|||
} else {
|
||||
/* coltype == SQLITE_BLOB */
|
||||
const char *blob = sqlite3_column_blob(self->statement->st, i);
|
||||
if (!blob) {
|
||||
converted = Py_NewRef(Py_None);
|
||||
} else {
|
||||
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
||||
converted = PyBytes_FromStringAndSize(blob, nbytes);
|
||||
}
|
||||
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
||||
converted = PyBytes_FromStringAndSize(blob, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue