Skip to content

gh-155702: Fix sqlite3.Blob slice assignment with a step - #155703

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-155702-blob-singleton-corruption
Aug 14, 2026
Merged

gh-155702: Fix sqlite3.Blob slice assignment with a step#155703
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-155702-blob-singleton-corruption

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 13, 2026

Copy link
Copy Markdown
Member

ass_subscript_slice() patched the bytes object read from the blob and wrote it back.
For a single byte that object is an immortal singleton, so the value of that byte was changed in the whole process.

It now reads into a plain buffer.
The raw read is factored out of read_multiple() into inner_read(), like the existing inner_write().

The negative step case (gh-150449, GH-150450) still raises the same ValueError as before.

It patched the bytes object read from the blob, which for a single byte
is an immortal singleton, so that the value of that byte was changed in
the whole process.

Read into a plain buffer instead.  The raw read is factored out of
read_multiple() into inner_read().

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@serhiy-storchaka
serhiy-storchaka merged commit b758ff4 into python:main Aug 14, 2026
62 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.15.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the gh-155702-blob-singleton-corruption branch August 14, 2026 04:38
@bedevere-app

bedevere-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

GH-155765 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 14, 2026
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
…nGH-155703)

It patched the bytes object read from the blob, which for a single byte
is an immortal singleton, so that the value of that byte was changed in
the whole process.
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.

2 participants