Repository navigation
Conversation
… helpers realloc_buffer_lock_held() reallocates to an exact size, unsharing if needed; prepare_write_lock_held() ensures a private buffer of at least the given size with the existing overallocation policy. Callers no longer open-code the shared/unshared choice. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
truncate() past the end now zero-fills, as IOBase.truncate() documents. A buffer shared with the caller is unshared first, even when the new size fits the current allocation. _pyio.StringIO inherits this through _pyio.BytesIO; the C StringIO does not extend. The two already disagree on truncate units (code points vs UTF-8 bytes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Documentation build overview
|
… buffers The loop wrote to both streams first, so neither started shared, and which path the second size took depended on the build: getvalue() leaves the buffer shared on free-threading (sticky buf_shared) but not on the default build once its result is dropped. Use a fresh shared and private stream for each size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
BytesIO.truncate()past the end now zero-fills, asIOBase.truncate()documents. A buffer shared with the caller (initial bytes,getvalue()) is unshared first, so the caller's bytes are never written.To support this,
resize_buffer_lock_held()is split intorealloc_buffer_lock_held()(exact size) andprepare_write_lock_held()(private, overallocated)._pyio.StringIOalso extends now, via_pyio.BytesIO; the CStringIOdoes not._pyio.StringIOand_io.StringIOalready differ in truncate units (code points vs UTF-8 bytes). For now leaving that gap.