gh-111331: Allow closing BytesIO with exported buffers - #155383
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-111331: Allow closing BytesIO with exported buffers#155383serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
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.
Documentation build overview
|
cmaloney
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing a
BytesIOobject which has exported buffers failed withBufferError, 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
BytesIOobject 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.