Skip to content

[3.15] gh-159739: Recheck BytesIO state after converting truncate size (GH-160190) - #160384

Merged
JelleZijlstra merged 1 commit into
python:3.15from
miss-islington:backport-8bfda55-3.15
Oct 23, 2026
Merged

JelleZijlstra merged 1 commit into
python:3.15from
miss-islington:backport-8bfda55-3.15

Conversation

@miss-islington

@miss-islington miss-islington 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.
(cherry picked from commit 8bfda55)

Co-authored-by: Jelle Zijlstra jelle@openai.com

…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 <jelle@openai.com>
@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) October 22, 2026 22:30
@JelleZijlstra
JelleZijlstra merged commit 45f5b00 into python:3.15 Oct 23, 2026
54 checks passed
@miss-islington
miss-islington deleted the backport-8bfda55-3.15 branch October 23, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants