fix: add explicit encoding="utf-8" to text-mode file I/O#784
Open
Ghraven wants to merge 1 commit into
Open
Conversation
Several text-mode open() calls relied on the platform default encoding (cp1252 on Windows) when reading/writing JSON test-case files, the JSONL streamlit log, and the bundled index.html. JSON and JSONL are UTF-8 per RFC 8259, so non-ASCII content could raise UnicodeDecodeError or be corrupted on non-UTF-8 platforms. Pinning encoding="utf-8" makes behavior consistent everywhere.
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.
What
Several text-mode
open()calls inburr/do not specify an encoding, so they fall back to the platform default (locale.getpreferredencoding()), which is cp1252 on Windows rather than UTF-8:burr/cli/__main__.pyburr/testing/__init__.pyburr/integrations/streamlit.pyburr/tracking/server/run.pyindex.htmlat startupWhy it matters
JSON and JSONL are defined as UTF-8 (RFC 8259). On a non-UTF-8 platform, any non-ASCII content in tracked state, test cases, or the UI bundle would raise
UnicodeDecodeErroror be silently corrupted, even though the files are valid UTF-8.Fix
Added
encoding="utf-8"to each affected text-modeopen()call. No behavior change on systems that already default to UTF-8, since UTF-8 is a strict superset of ASCII.Verification
All four files still parse and import. The existing append-mode log handle in
tracking/client.pyalready setsencoding="utf-8", so this aligns the rest of the file I/O with that convention. Happy to adjust scope if you would prefer these split up.