Repository navigation
Preserve unread text when SpooledStringIO rolls over - #582
Open
Aryangupta-05 wants to merge 1 commit into
Open
Aryangupta-05 wants to merge 1 commit into
Aryangupta-05 wants to merge 1 commit into
Conversation
Retain pending UTF-8 bytes, decoded characters and buffered lines so rollover and fileno do not skip unread text or start decoding mid-character. Fixes mahmoud#581. AI assistance: OpenAI Codex (GPT-6) investigated, implemented and validated this change at the account owner request.
This branch has not been deployed
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.
The change
Fixes #581. Preserve the UTF-8 reader's pending bytes, decoded characters and buffered lines when
SpooledStringIOrolls over to a temporary file. Keeping only the underlying byte position skips unread text afterreadline()and can raiseUnicodeDecodeErrorif read-ahead ended inside a multibyte character.The patch keeps the existing byte position and transfers the reader buffers, preserving existing read/write behavior. Tests cover explicit rollover,
fileno(), automatic rollover during a write, multiline and multibyte text, and a length-query compatibility boundary. Existing length-query behavior is outside this fix's scope.Validation: full tests and doctests on Windows / CPython 3.11: 681 passed, 18 subtests passed.
git diff --checkpassed. The regression tests fail on the original implementation with skipped text or a Unicode decoding error. The full suite needed normal local socket access for an unrelated Windows asyncio test.The backstory
i'm getting started with open source and want to learn by fixing real bugs. small, reusable python utilities interest me because they're a practical way to understand how reliable library code is built. this report was selected while looking for an existing bug to contribute to; it did not come from prior production use of boltons.
AI assistance
now conitnue to do your work. When asked for a personal backstory, the owner requestedgenrate a sentnce and make it all in lower case letter and human text. The backstory above is a disclosed draft based on that stated intent.