Skip to content

[3.15] gh-150449: Raise ValueError for sqlite3.Blob slices with a negative step - #155773

Merged
serhiy-storchaka merged 2 commits into
python:3.15from
serhiy-storchaka:backport-150450-3.15
Oct 9, 2026
Merged

serhiy-storchaka merged 2 commits into
python:3.15from
serhiy-storchaka:backport-150450-3.15

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Reading or writing a Blob slice with a negative step computed a negative length and failed with SystemError, which means an internal error.
It now raises ValueError.

Empty slices, which select nothing, are still allowed: blob[3:8:-1] returns b"" and assigning b"" to it is a no-op.

Support for negative steps is added in 3.16 by GH-150450.

…tive step

Reading or writing such a slice computed a negative length and failed with
SystemError.  Empty slices, which select nothing, are still allowed.

(cherry picked from commit d9e8d226a3d05ea020256086aee24d21f9792206)
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 9, 2026
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) October 9, 2026 18:04
@serhiy-storchaka serhiy-storchaka removed needs backport to 3.13 only security fixes type-feature A feature request or enhancement labels Oct 9, 2026
@serhiy-storchaka
serhiy-storchaka merged commit 503560d into python:3.15 Oct 9, 2026
55 of 59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 503560dcadd9eaa42f152115b495143f1fc64ff2 3.14

@bedevere-app

bedevere-app Bot commented Oct 10, 2026

Copy link
Copy Markdown

GH-159110 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 10, 2026
serhiy-storchaka added a commit that referenced this pull request Oct 10, 2026
…ative step (GH-155773) (GH-159110)

Reading or writing such a slice computed a negative length and failed with
SystemError.  Empty slices, which select nothing, are still allowed.
(cherry picked from commit 503560d)


(cherry picked from commit d9e8d226a3d05ea020256086aee24d21f9792206)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant