fix(workspace): write and read the vault as UTF-8, not the host locale - #418
Open
MohammedAlkindi wants to merge 1 commit into
Open
fix(workspace): write and read the vault as UTF-8, not the host locale#418MohammedAlkindi wants to merge 1 commit into
MohammedAlkindi wants to merge 1 commit into
Conversation
AntonSettings loads .anton/.env with env_file_encoding="utf-8" (config/settings.py:32), but Workspace wrote and read that file, and anton.md, with bare read_text/write_text. Those use locale.getpreferredencoding(), which is cp1252 on a Western Windows install, so a non-ASCII secret was stored as bytes the settings loader cannot decode and every later AntonSettings() raised UnicodeDecodeError. A value outside the code page, such as a CJK string, raised UnicodeEncodeError on write and was never stored at all. The same two-line issue applied to the consent write in cli._ensure_terms_consent.
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.
AntonSettingsloads.anton/.envwithenv_file_encoding="utf-8"(anton/config/settings.py:32), butWorkspacewrote and read that file, andanton.md, with bareread_text/write_text. Those uselocale.getpreferredencoding(), which is cp1252 on a Western Windows install, so the writer and the loader disagree.Two consequences, both silent until they are not:
AntonSettings()raisesUnicodeDecodeError;UnicodeEncodeErroron write and is never stored at all.Five tests cover it. Four are behavioural; the fifth runs the workspace under
-X warn_default_encoding(PEP 597) and asserts noEncodingWarningnamesworkspace.py, which keeps the regression visible on UTF-8 CI where the behavioural four pass either way.All five fail on the unpatched tree and pass with the change.
Scoped to the nine test modules that reach
Workspaceorcli: 403 passed / 9 failed before, 408 passed / 9 failed after, with a byte-identical set of failing names. The nine are pre-existing clipboard, network and POSIX-permission tests unrelated to this change.The same two lines applied to the consent write in
cli._ensure_terms_consent.