mirror of
https://github.com/python/cpython.git
synced 2026-04-13 23:31:02 +00:00
[3.13] gh-142787: Handle empty sqlite3 blob slices (GH-142824) (#145298)
(cherry picked from commit 06b0920f12)
Co-authored-by: A.Ibrahim <abdulrasheedibrahim47@gmail.com>
This commit is contained in:
parent
083477fbd6
commit
cd3e9b3fd2
3 changed files with 11 additions and 0 deletions
|
|
@ -1410,6 +1410,11 @@ def test_blob_get_slice(self):
|
|||
def test_blob_get_empty_slice(self):
|
||||
self.assertEqual(self.blob[5:5], b"")
|
||||
|
||||
def test_blob_get_empty_slice_oob_indices(self):
|
||||
self.cx.execute("insert into test(b) values (?)", (b"abc",))
|
||||
with self.cx.blobopen("test", "b", 2) as blob:
|
||||
self.assertEqual(blob[5:-5], b"")
|
||||
|
||||
def test_blob_get_slice_negative_index(self):
|
||||
self.assertEqual(self.blob[5:-5], self.data[5:-5])
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Fix assertion failure in :mod:`sqlite3` blob subscript when slicing with
|
||||
indices that result in an empty slice.
|
||||
|
|
@ -428,6 +428,10 @@ subscript_slice(pysqlite_Blob *self, PyObject *item)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return PyBytes_FromStringAndSize(NULL, 0);
|
||||
}
|
||||
|
||||
if (step == 1) {
|
||||
return read_multiple(self, len, start);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue