Skip to content

fix: keep CLI status output usable under ASCII locales - #125

Merged
abhiksark merged 1 commit into
devfrom
fix/issue-73
Aug 20, 2026
Merged

fix: keep CLI status output usable under ASCII locales#125
abhiksark merged 1 commit into
devfrom
fix/issue-73

Conversation

@abhiksark

Copy link
Copy Markdown
Owner

Closes #73.

verify and list crashed with UnicodeEncodeError on any console whose encoding cannot represent their status glyphs. Status symbols now fall back to one-column ASCII stand-ins when the stream cannot encode them, and keep the Unicode glyphs when it can:

state UTF-8 fallback
pass +
fail x
current >
locked 🔒 -

The issue's recorded scope was narrower than the bug. It names verify and list, but solution and run crash on a different path — they write the check file's captured output, and all 292 checks end with print("<name> ✓"). That glyph comes from the curriculum, not from our formatting, so degrading the CLI's own symbols would not have fixed those commands. All captured subprocess output now goes through a writer that replaces unencodable characters instead of raising.

Found while packaging for conda-forge: the win-64 test runs in a pipe using cp1252, and pythonlings solution variables1 died there.

Verification

python -m pytest -q                                          212 passed
pythonlings --root tests/fixtures/passing_curriculum verify  exit 0

Both new integration tests fail against the unpatched cli.py and pass with it. They pin PYTHONIOENCODING explicitly so the regression is deterministic rather than locale-dependent, and cover the UTF-8 path as well as the fallback.

$ LC_ALL=C PYTHONIOENCODING=ascii pythonlings --root tests/fixtures/tiny_curriculum list exercises
    >  passing
    -  asserts
    -  syntax
    -  pending

Exit codes and command semantics are unchanged; the TUI is untouched.

Closes #73.

The CLI rendered Unicode status glyphs unconditionally, so verify and list
crashed with UnicodeEncodeError on any console whose encoding cannot represent
them -- LC_ALL=C, or a Windows code page. Status symbols now fall back to
one-column ASCII stand-ins (+ pass, x fail, > current, - locked) when the
stream cannot encode them, and keep the Unicode glyphs when it can.

The issue recorded verify and list, but solution and run crash on a separate
path: they write the check file's captured output, and every check ends with
print("<name> ✓"). That glyph comes from the curriculum rather than from
our own formatting, so degrading the CLI's symbols alone would not have fixed
it. All captured subprocess output now goes through a writer that replaces
characters the encoding cannot represent rather than raising.

This surfaced as a win-64 failure while packaging for conda-forge, where the
test console is a pipe using cp1252.

Integration coverage pins PYTHONIOENCODING explicitly so the regression is
deterministic rather than dependent on the locale the suite runs under, and
covers both the ASCII fallback and the UTF-8 path.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 25fbcca4-9662-4120-8e8d-f7a3d24b9c3b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@abhiksark
abhiksark merged commit b221f90 into dev Aug 20, 2026
6 checks passed
abhiksark added a commit to xjcway123/pythonlings that referenced this pull request Aug 21, 2026
Brings in the Windows and macOS CI matrix (abhiksark#126) so this TUI change is
exercised on Windows before merge, plus the ASCII-locale CLI fix (abhiksark#125).
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.

1 participant