Repository navigation
fix: read /source and editor files as UTF-8 - #2432
Merged
Merged
Conversation
/source and the \e editor file were opened with the locale default encoding, so UTF-8 SQL files were mis-decoded or rejected under non-UTF-8 locales (Windows cp1252/cp932, LANG=C). Pass encoding='utf-8', matching the config and history files.
Contributor
|
Thanks again! Windows improvements greatly appreciated. The only thing I could ask is for the changelog entry to be more concise. |
Contributor
|
Released in https://github.com/dbcli/mycli/releases/tag/v2.31.0 ! |
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.
Follow-up to #2429: the same locale-encoding bug in the two remaining read paths (
/sourceand the\eeditor file).Description
/source <file>(execute_from_fileinclient_commands.py) and the\e <file>editor read (open_external_editorinio_commands.py) opened the file with the locale's default encoding. Under a non-UTF-8 locale (Windows cp1252/cp932,LANG=C) a UTF-8 SQL file containing non-ASCII text is mis-decoded or rejected. The config and history files already passencoding='utf-8'; these twoopen()calls were missing it.Fix: pass
encoding='utf-8'in both places, plus a changelog entry.Tests: two new tests run the code in a subprocess with
-X warn_default_encoding -W error::EncodingWarning, which fails onmain(EncodingWarning: 'encoding' argument not specified) and passes with the fix. The existingopenmocks intest_client_commands.pynow accept the extra keyword.Disclosure: this change was prepared with the help of an AI coding assistant (Claude); the submitter is responsible for it.
Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).ruff checkandruff format --checkpass on the touched files;mypynot run (only anencodingkeyword was added).