Repository navigation
Honor the encoding when reading lines in reverse - #463
Closed
codewithfourtix wants to merge 1 commit into
Closed
codewithfourtix wants to merge 1 commit into
codewithfourtix wants to merge 1 commit into
Conversation
Signed-off-by: Ali Zulfiqar <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The change is small, directly addresses the stated bug, and includes targeted regression tests for both affected scenarios (text and binary streams).
Pull request overview
This PR fixes reverse_iter_lines() so it no longer forces UTF-8 for text streams and no longer discards an explicitly provided encoding for binary streams, ensuring reverse line iteration decodes using the caller-supplied encoding (or the stream’s own encoding when available).
Changes:
- Update
reverse_iter_lines()to selectencodingfrom the explicit argument first, then fall back tofile_obj.encodingwhen present. - Add regression tests covering Latin-1 decoding for both a text stream (with an encoding) and a binary stream (with an explicit encoding).
File summaries
| File | Description |
|---|---|
| tests/test_jsonutils.py | Adds regression tests verifying encoding is honored for both text and binary streams. |
| boltons/jsonutils.py | Fixes encoding selection logic to preserve caller/stream encodings instead of forcing UTF-8. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mahmoud
added a commit
that referenced
this pull request
Sep 7, 2026
Fold #463, #466, #476, #478, #460, #459, and #477 with focused regressions and 26.2.0 release notes. Verified 672 local tests and the full GitHub Actions matrix before merge. Co-authored-by: Ali Zulfiqar <[email protected]> Co-authored-by: Guo Jiarui <[email protected]> Co-authored-by: Nikolaus Schuetz <[email protected]> Co-authored-by: Raiyan Zaman <[email protected]>
Owner
|
Folded into #481 with credit (Co-authored-by). Thanks! |
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.
reverse_iter_lines()overwrites a text stream's encoding with UTF-8 and drops an explicit encoding for binary streams. Use the supplied encoding, falling back to the stream's encoding when available.Adds Latin-1 text-stream and binary-stream regression tests.