Repository navigation
Conversation
load_alias_map_file() opened the JSON file in text mode with the locale encoding. On Windows that is a legacy code page such as cp932 or cp1252, so a UTF-8 alias map with non-ASCII table names either raised UnicodeDecodeError (not caught, so pgcli failed to start) or was decoded into mojibake that never matched the table name. A BOM written by some Windows editors was also rejected as invalid JSON on every platform. Open the file in binary mode and let json detect the encoding, which handles UTF-8 with or without a BOM regardless of the locale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@b84330808 thanks for the PR! Looks good, but I see tests failing. Can you take a look? |
Author
|
Thanks for taking a look! The only failure is |
This branch has not been deployed
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.
Description
load_alias_map_file()opened thealias_map_fileJSON with the locale encoding. On Windows that's a legacy code page (cp932 on Japanese Windows, cp1252 on English Windows), so a UTF-8 alias map with non-ASCII table names either stopped pgcli from starting with aUnicodeDecodeError(onlyFileNotFoundErrorandJSONDecodeErrorare caught there) or got decoded into mojibake that never matched the table name. A file saved with a BOM, which some Windows editors add, was rejected as "not valid json" on every platform.The file is now opened in binary mode, so
jsondetects the encoding itself (UTF-8 with or without a BOM, like any JSON file).Example on Japanese Windows, with
{"注文明細": "om"}as the alias map:With the change the alias for
注文明細isom. The new test fails without the change on Windows (both cases) and on Linux for the BOM case.Checklist
changelog.rst.AUTHORSfile (or it's already there).pip install pre-commit && pre-commit install).I used Claude Code to write this change.