Fix progress tracking for multibyte text files - #856
Open
RamiNoodle733 wants to merge 2 commits into
Open
Conversation
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.
Fixes #439.
The progress bar currently uses the file size in bytes as its total, but
UpdateWrapperadvances it usinglen()on decoded text. That makes UTF-16 input finish near 50% and can also miscount other multibyte encodings.This changes
UpdateWrapperto advance from the wrapped stream'stell()position. Iteration usesreadline()soTextIOWrapper.tell()remains available and reports the logical position in the underlying byte stream. Non-seekable streams retain the previouslen()fallback.Regression coverage checks UTF-8, UTF-16-LE, UTF-32-LE, CRLF translation, and the
read()path.Validation performed locally with a focused Python reproducer for those byte-count cases. The full repository test suite was not run because this runtime could not resolve github.com for a checkout.
📚 Documentation preview 📚: https://sqlite-utils--856.org.readthedocs.build/en/856/