Skip to content

gh-159739: Recheck BytesIO state after converting truncate size - #160190

Merged
JelleZijlstra merged 2 commits into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-bytesio-truncate-state
Oct 22, 2026
Merged

JelleZijlstra merged 2 commits into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-bytesio-truncate-state

Conversation

@jelle-openai

@jelle-openai jelle-openai commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

A size object's __index__() can close a BytesIO or export its buffer after truncate() checks the stream. Continuing can dereference a cleared buffer or resize storage behind a live view. Recheck the stream state after size conversion. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_memoryio.py.

A size object's __index__() can close a BytesIO or export its buffer after truncate() checks the stream. Continuing can dereference a cleared buffer or resize storage behind a live view. Recheck the stream state after size conversion. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_memoryio.py.
Comment thread Misc/NEWS.d/next/Library/2026-10-21-21-26-10.gh-issue-159739.rVWF2a.rst Outdated
@JelleZijlstra
JelleZijlstra merged commit 8bfda55 into python:main Oct 22, 2026
56 checks passed
@JelleZijlstra JelleZijlstra added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 22, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 22, 2026
…pythonGH-160190)

A size object's __index__() can close a BytesIO or export its buffer after truncate() checks the stream. Continuing can dereference a cleared buffer or resize storage behind a live view. Recheck the stream state after size conversion. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_memoryio.py.
(cherry picked from commit 8bfda55)

Co-authored-by: Jelle Zijlstra <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 22, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 22, 2026
@bedevere-app

bedevere-app Bot commented Oct 22, 2026

Copy link
Copy Markdown

GH-160385 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 22, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry @jelle-openai and @JelleZijlstra, I had trouble completing the backport.

Please retry by removing and re-adding the "needs backport to 3.14" label.
If that does not work, please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 8bfda5553c0f8ac1163b4ce4ca7b8b632a853f51 3.14

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 22, 2026
…pythonGH-160190)

A size object's __index__() can close a BytesIO or export its buffer after truncate() checks the stream. Continuing can dereference a cleared buffer or resize storage behind a live view. Recheck the stream state after size conversion. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_memoryio.py.
(cherry picked from commit 8bfda55)

Co-authored-by: Jelle Zijlstra <[email protected]>
@miss-islington-app

Copy link
Copy Markdown

Sorry @jelle-openai and @JelleZijlstra, I had trouble completing the backport.

Please retry by removing and re-adding the "needs backport to 3.15" label.
If that does not work, please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 8bfda5553c0f8ac1163b4ce4ca7b8b632a853f51 3.15

JelleZijlstra pushed a commit that referenced this pull request Oct 23, 2026
GH-160190) (#160384)

A size object's __index__() can close a BytesIO or export its buffer after truncate() checks the stream. Continuing can dereference a cleared buffer or resize storage behind a live view. Recheck the stream state after size conversion. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_memoryio.py.
(cherry picked from commit 8bfda55)

Co-authored-by: Jelle Zijlstra <[email protected]>
JelleZijlstra pushed a commit that referenced this pull request Oct 23, 2026
GH-160190) (#160385)

A size object's __index__() can close a BytesIO or export its buffer after truncate() checks the stream. Continuing can dereference a cleared buffer or resize storage behind a live view. Recheck the stream state after size conversion. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_memoryio.py.
(cherry picked from commit 8bfda55)

Co-authored-by: Jelle Zijlstra <[email protected]>
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