Skip to content

gh-111331: Allow closing BytesIO with exported buffers - #155383

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-111331-bytesio-close-exports
Open

gh-111331: Allow closing BytesIO with exported buffers#155383
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-111331-bytesio-close-exports

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Closing a BytesIO object which has exported buffers failed with BufferError, so destroying or garbage collecting such object emitted an unraisable exception.

Every exported buffer now keeps a reference to the internal buffer, so it outlives closing of the BytesIO object and stays usable.

The pure Python implementation was fixed in GH-152335. The C implementation now behaves the same, so the tests no longer need to be skipped for it.

close() no longer fails with BufferError if there are exported buffers.
Every exported buffer keeps a reference to the internal buffer, so it
outlives closing of the BytesIO object.  As a result, destroying or garbage
collecting such object no longer emits an unraisable exception.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33973540 | 📁 Comparing 9de3bc3 against main (998b890)

  🔍 Preview build  

2 files changed
± library/io.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants