Repository navigation
Read and write default myclirc as UTF-8 - #2389
Merged
Merged
Conversation
The packaged myclirc is UTF-8 and contains non-ASCII text (en dashes in the prompt format comments), but it was opened with the locale encoding. On Windows with a CJK code page such as cp932, mycli crashed with UnicodeDecodeError on every startup, and writing ~/.myclirc on first run would fail the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Thank you! |
Contributor
|
Going out now in release https://github.com/dbcli/mycli/releases/tag/v2.30.2 . |
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
On Windows with a CJK code page (cp932 here, and cp936/cp949/cp950 fail the same way), mycli crashes on every startup unless Python's UTF-8 mode is on:
The packaged
myclircis UTF-8 and has en dashes in the prompt comments ((00–23),(01–12), since 32fe310 / v1.54.0). Butcreate_default_config()andwrite_default_config()open it with the locale encoding, and the first-run~/.myclircis also written with the locale encoding. User config files were already read as UTF-8.#985 fixed the same crash in 2021 by removing a dash (#978, #998). This change reads and writes the file as UTF-8 instead, so the crash won't come back the next time the comments change.
Windows CI doesn't catch this because the runners use cp1252, and those bytes decode there (as mojibake). The new test runs both functions in a subprocess with
-X warn_default_encoding -W error::EncodingWarning:mycli.config, so it fails on any OS if the default config is opened without an encoding again.I used Claude Code to write this change.
Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).