Repository navigation
Conversation
`test_read_lines_lossy_preserves_lines_after_invalid_utf8` asserted that
the bad byte becomes U+FFFD. That only holds when no code page applies.
`read_lines_lossy` decodes through the console code page, so on cp437
`0xE3` is a valid character (pi) and on cp1252 it is a-tilde -- the
assertion fails on a correctly working decoder:
panicked at src/core/stream.rs:611: got: "ERRO B: pi"
The property the test exists to protect is not which character comes
out, it is that one bad byte does not swallow the rest of the line.
Assert that instead: the line is the prefix plus exactly one character,
whatever that character decodes to.
CI passes either way because its console has no code page to consult.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 20, 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.
Problem
test_read_lines_lossy_preserves_lines_after_invalid_utf8asserts that the injected bad byte becomesU+FFFD. That is only true when there is no console code page to consult.read_lines_lossydecodes through the console code page, so on a machine where one applies the byte legitimately decodes to a real character —0xE3isπon cp437,ãon cp1252 — and the test fails against a correctly working decoder:CI passes either way because a fresh runner's console has no code page to apply.
Fix
The property this test exists to protect is not which character comes out — it is that one bad byte does not swallow the rest of the line. Assert that directly: the line is its prefix plus exactly one character, whatever that character decodes to. The surrounding assertions (line count, the lines before and after) are unchanged, so the regression it was written for is still pinned.
Scope
Standalone on purpose. This is an existing test of yours, unrelated to any feature work, so it is not bundled with anything else.
Testing
cargo clippy --all-targetsclean.🤖 Generated with Claude Code