Files
Jiseok CHOI ce79cd4853 sqlite3: fix Blob.__setitem__ value range validation (#7981)
* sqlite3: fix Blob.__setitem__ value range validation

Previously, assigning an out-of-range integer (negative or > 255) or an
integer too large for i64 (e.g. 2**65) to a Blob index raised OverflowError
instead of ValueError.

Mirror CPython's ass_subscript_index logic:
- Convert the value via to_i64(), treating any overflow as -1
- Validate the result is in [0, 255], raising ValueError("byte must be in range(0, 256)") otherwise
- Separate deletion error messages: "item deletion" for index, "slice deletion" for slice

* sqlite3: fix Blob.__setitem__ negative-step slice write

In the step != 1 branch of Blob.ass_subscript, the loop used
  i_in_temp += step as usize
where step is isize. For negative steps (e.g. step = -2),
  (-2isize) as usize = 18446744073709551614
causing an out-of-bounds panic whenever slice_len >= 2.

Fix: use SaturatedSliceIter (already used by the read path) to iterate
over the correct absolute blob indices, then map each index back to a
temp buffer offset via abs_idx - range_start.

Also fix a Clippy lint: replace
  val < 0 || val > 255
with the idiomatic
  !(0..=255).contains(&val)

Add a regression test in extra_tests/snippets/stdlib_sqlite.py that
exercises blob[9:0:-2] (negative step, slice_len=5).

* fix: guard blob negative-step snippet from CPython 3.11 bug

* style: add blank line after import sys in stdlib_sqlite snippet (ruff)

* Update extra_tests/snippets/stdlib_sqlite.py

---------

Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
2026-05-27 16:40:05 +09:00
..
2025-12-12 22:46:39 +09:00
2020-09-13 06:58:57 +09:00
2020-09-13 06:58:57 +09:00
2020-09-13 06:58:57 +09:00
2020-09-13 06:58:57 +09:00
2020-09-13 06:58:57 +09:00
2020-09-13 06:58:57 +09:00
2025-11-15 23:09:31 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2026-01-17 19:21:10 +09:00
2026-01-17 19:21:11 +09:00
2025-06-22 00:00:07 +09:00
2025-07-07 19:02:37 +09:00
2026-01-17 19:21:11 +09:00
2020-09-13 06:58:57 +09:00
2026-01-29 16:48:02 +09:00
2025-12-12 22:46:39 +09:00
2020-09-13 06:58:57 +09:00
2026-01-17 19:21:11 +09:00
2026-01-17 19:21:11 +09:00
2020-09-13 06:58:57 +09:00
2025-12-12 22:46:39 +09:00
2020-09-13 06:58:57 +09:00
2025-05-12 14:20:01 +09:00
2025-05-12 14:20:01 +09:00
2025-12-12 22:46:39 +09:00
2026-02-08 13:58:30 +00:00
2022-10-17 13:45:15 +09:00
2023-05-23 16:43:52 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2020-09-13 06:58:57 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2026-01-17 19:21:11 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2025-12-12 22:46:39 +09:00
2023-05-19 14:05:36 -04:00
2025-02-13 14:11:01 +09:00
2023-02-13 21:28:19 +09:00
2022-05-04 02:54:59 +09:00
2025-08-26 21:48:46 +09:00
2026-03-08 22:53:26 +09:00
2020-09-13 06:58:57 +09:00