fix: preserve UTF-8 text at sample boundaries - #79834
Closed
cgordoncarroll wants to merge 1 commit into
Closed
Conversation
Closed
1 task
Contributor
|
Closing — superseded by #81961, which fixed this bug class (1000-byte sample cutting a multibyte char → binary false positive) at the byte layer across read_file, patch, and search_files, with regression tests for truncated-CJK/BOM/UTF-16/NUL cases. ~24 PRs raced on this one; earliest diagnosis credit to @webtecnica (#76924), merged implementation from @ayushnangia (#80440). Thanks for jumping on it. |
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.
Summary
read_fileandread_file_rawRoot cause
The terminal backend decodes subprocess output with replacement semantics. When
head -c 1000ended inside a multibyte UTF-8 code point, the orphaned lead byte becameU+FFFD;_is_likely_binarythen rejected an otherwise valid UTF-8 Markdown file as binary.Verification
170 passedacross:tests/tools/test_file_operations.pytests/tools/test_file_operations_edge_cases.pytests/tools/test_file_ops_cwd_tracking.pytests/tools/test_file_read_guards.pytests/tools/test_file_tools.pytests/tools/test_file_tools_cwd_resolution.pytests/tools/test_file_tools_tilde_profile.pymain