Skip to content

[3.14] gh-160324: Keep io.StringIO state after MemoryError (GH-160325) - #161042

Open
miss-islington wants to merge 1 commit into
python:3.14from
miss-islington:backport-83b047e-3.14
Open

miss-islington wants to merge 1 commit into
python:3.14from
miss-islington:backport-83b047e-3.14

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Allocate before consuming the accumulated writes in realize() and
make_intermediate(), and reset the size when the contents are lost,
so that later calls do not index outside the internal buffer.

Shrink the buffer of the accumulating writer before finishing it, so
that getvalue(), read() and the other methods leave the contents
unchanged when they fail with MemoryError instead of dropping them.

ANT-2026-MPHGX2FL
(cherry picked from commit 83b047e)

Co-authored-by: Gregory P. Smith 68491+gpshead@users.noreply.github.com

…GH-160325)

Allocate before consuming the accumulated writes in realize() and
make_intermediate(), and reset the size when the contents are lost,
so that later calls do not index outside the internal buffer.

Shrink the buffer of the accumulating writer before finishing it, so
that getvalue(), read() and the other methods leave the contents
unchanged when they fail with MemoryError instead of dropping them.

ANT-2026-MPHGX2FL
(cherry picked from commit 83b047e)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants