Skip to content

fix: read password file and contributor/sponsor/tip files as UTF-8 - #2444

Merged
rolandwalker merged 1 commit into
dbcli:mainfrom
pcbeingused333:fix/open-encoding-c4232
Nov 18, 2026
Merged

rolandwalker merged 1 commit into
dbcli:mainfrom
pcbeingused333:fix/open-encoding-c4232

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Follow-up to #2429 and #2432: the same locale-encoding bug in the remaining open() calls.

Description

get_password_from_file (main.py) and the AUTHORS.txt, SPONSORS.txt and TIPS.txt readers in main_modes/repl.py opened files with the locale's default encoding. Under a non-UTF-8 locale (Windows cp1252/cp932, LANG=C) a UTF-8 password file with non-ASCII characters is mis-decoded (wrong password) or rejected, and contributor names with accents show up as mojibake or raise UnicodeDecodeError. The config, history, /source and audit/tee files already pass encoding='utf-8'; these four calls were missing it.

Fix: pass encoding='utf-8' in the four 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 on main (EncodingWarning: 'encoding' argument not specified) and passes with the fix. The FakeResourceTree.open test double now accepts the extra keyword.

Disclosure: this change was prepared with the help of an AI coding assistant (Claude); the submitter is responsible for it.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the mycli/AUTHORS.txt file (or it's already there).
  • ruff check and ruff format --check pass on the touched files; mypy not run (only an encoding keyword was added).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rolandwalker

Copy link
Copy Markdown
Contributor

Thanks! The only thing I could ask for is a more concise changelog entry.

@rolandwalker
rolandwalker merged commit 18f800d into dbcli:main Nov 18, 2026
13 checks passed
@rolandwalker

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants