gh-157242: Do not close io.BytesIO on MemoryError (#157344) · python/cpython@23eda00 · GitHub
Skip to content

Commit 23eda00

Browse files
authored
gh-157242: Do not close io.BytesIO on MemoryError (#157344)
Replace _PyBytes_Resize() with _PyBytes_ResizeKeepOnError(). Fix truncate(): on error, restore string_size to its previous value.
1 parent 7bfa97f commit 23eda00

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

Lib/test/test_io/test_memoryio.py

Lines changed: 30 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:class:`io.BytesIO` is no longer closed on ``write()`` and ``truncate()``
2+
failure (:exc:`MemoryError`). Patch by Victor Stinner.

Modules/_io/bytesio.c

Lines changed: 6 additions & 2 deletions

0 commit comments

Comments
 (0)