Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
af0eb65
gh-150449: Fix sqlite3.Blob crash with negative-step slices
ever0de May 26, 2026
85312b4
gh-150449: validate slice assignment size even for empty slices
ever0de May 26, 2026
c0c2018
gh-150449: add tests for negative-step slices with start <= stop
ever0de May 26, 2026
83d3a3c
Fix PEP 7 line-length violations in blob.c (ass_subscript_slice)
ever0de May 26, 2026
f7c9f53
gh-150449: Address review: docs, tests, and rename write_offset
ever0de May 30, 2026
5087b42
gh-150449: Fix versionchanged version: use 'next' not '3.16'
ever0de May 30, 2026
d774ab7
gh-150449: Fix wording in NEWS and whatsnew: 'crash' → 'raise SystemE…
ever0de May 30, 2026
5bf02de
gh-150449: Remove redundant issue references from test comments
ever0de May 30, 2026
c311c8e
Merge remote-tracking branch 'upstream/main' into gh-150449-fix-sqlit…
ever0de May 30, 2026
d4b4b43
gh-150449: Fix missing blank line after xml section in whatsnew
ever0de May 30, 2026
0936d6b
gh-150449: Rename read_length to write_length in ass_subscript_slice
ever0de May 30, 2026
5f2f916
gh-150449: Move empty-slice validation fix to dedicated PR for gh-150913
ever0de Jun 4, 2026
d47abf8
Merge remote-tracking branch 'upstream/main' into gh-150449-fix-sqlit…
ever0de Jun 4, 2026
be1aa18
gh-150449: Add tests for extreme step values in sqlite3.Blob slice op…
ever0de Jun 5, 2026
f76ebf7
gh-150449: Assert correctness of extreme-step slice assignment in sql…
ever0de Jun 5, 2026
52084f9
gh-150449: Isolate extreme-step Blob assignment tests
ever0de Jun 5, 2026
a462e70
Merge branch 'main' into gh-150449-fix-sqlite-blob-negative-step-slice
serhiy-storchaka Jun 8, 2026
d6e07f5
Merge branch 'main' into gh-150449-fix-sqlite-blob-negative-step-slice
serhiy-storchaka Aug 11, 2026
98fc681
Merge branch 'main' into gh-150449-fix-sqlite-blob-negative-step-slice
serhiy-storchaka Aug 13, 2026
c587f21
Merge branch 'main' into gh-150449-fix-sqlite-blob-negative-step-slice
serhiy-storchaka Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gh-150449: add tests for negative-step slices with start <= stop
Exercise the case where step is negative but start <= stop, which
produces an empty slice.  Verify that:
  - blob[3:8:-1] returns b"" (no crash)
  - blob[3:8:-1] = b"" is a no-op
  - blob[3:8:-1] = b"abc" raises IndexError (wrong size)

Also add blob[5:5:-1] == b"" to cover the start == stop edge case.
  • Loading branch information
ever0de committed May 26, 2026
commit c0c20185e8cff47684ce18597e50b9c759896a28
13 changes: 13 additions & 0 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,10 @@ def test_blob_get_slice_with_negative_step(self):
self.assertEqual(self.blob[9:0:-2], self.data[9:0:-2])
self.assertEqual(self.blob[9::-2], self.data[9::-2])
self.assertEqual(self.blob[::-1], self.data[::-1])
# When start <= stop with a negative step the slice is empty; this
# must return b"" rather than crashing or raising an exception.
self.assertEqual(self.blob[3:8:-1], self.data[3:8:-1]) # b""
self.assertEqual(self.blob[5:5:-1], self.data[5:5:-1]) # b""

def test_blob_set_slice(self):
self.blob[0:5] = b"12345"
Expand Down Expand Up @@ -1427,6 +1431,15 @@ def test_blob_set_slice_with_negative_step(self):
actual2 = self.cx.execute("select b from test").fetchone()[0]
self.assertEqual(actual2, bytes(expected2))

# When start <= stop with a negative step the slice is empty;
# assigning b"" to it must be a no-op (blob contents unchanged).
state_before = bytes(self.blob[:])
self.blob[3:8:-1] = b""
self.assertEqual(bytes(self.blob[:]), state_before)
# Assigning a non-empty sequence to an empty slice must raise.
with self.assertRaisesRegex(IndexError, "wrong size"):
self.blob[3:8:-1] = b"abc"

def test_blob_mapping_invalid_index_type(self):
msg = "indices must be integers"
with self.assertRaisesRegex(TypeError, msg):
Expand Down
Loading