Repository navigation
fix(encoding): PYTHONIOENCODING=utf-8 at airc startup (continuum's silent-drop catch) - #178
Merged
Merged
Conversation
…um's encoding-drop catch)
continuum-b69f traced 2026-04-27: many cross-machine messages were
getting SILENTLY DROPPED on Windows with:
[airc:formatter] skipped one line: 'charmap' codec can't encode
character '→' in position 37: character maps to <undefined>
Windows Python defaults to the local code page (cp1252 on US/EU
installs) for stdout. Common Unicode chars — →, em-dash, ✓, etc. —
have no cp1252 codepoint, so `print(...)` raises UnicodeEncodeError.
The formatter's per-line try/except catches it and skips, but from
the user's view the message is just missing from the stream.
## Fix
```bash
export PYTHONIOENCODING="${PYTHONIOENCODING:-utf-8}"
```
Set once at airc startup. Every Python subprocess airc spawns
inherits utf-8 stdio. Honors user override via the default-fallback.
Same shape as MSYS2_ARG_CONV_EXCL (#177) — environment-level fix
that benefits every airc_core invocation without per-callsite changes.
## Why this is the right shape (per Joel's "always the best")
Per-module sys.stdout reconfiguration is also possible, but:
- Requires editing every airc_core module
- Easy to miss a future module
- Doesn't help bash-side code that might also print Unicode
Setting PYTHONIOENCODING once at airc startup is the architectural
answer — Python is told globally to use utf-8 for stdio, and every
subprocess gets the right behavior automatically.
## Test posture
10 scenarios / 102 assertions green on Mac (env var is no-op on Mac
where Python defaults to utf-8 already, but the export is harmless).
Live python3 print of `→ ✓ ⚠ — em-dash` succeeds with the env var set.
## Follow-up
Closes the silent-drop class continuum filed earlier today as #163
(UTF-8 → Latin-1 double-decode). The PYTHONIOENCODING fix is more
general — it covers the OUTPUT side (Windows console encoding) AND
the INPUT side (Python reading stdin will also use utf-8). #163 can
be closed.
This was referenced Apr 28, 2026
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.
continuum-b69f traced silent message drops on Windows: `'charmap' codec can't encode character '→'...`. Windows Python defaults to cp1252 stdio; can't encode →, em-dashes, ✓, etc.; formatter catches the exception per-line; user just sees missing messages.
Fix
```bash
export PYTHONIOENCODING="${PYTHONIOENCODING:-utf-8}"
```
Once at airc startup. Every Python subprocess inherits utf-8 stdio. Same shape as #177's MSYS2_ARG_CONV_EXCL — env-level architectural fix.
Why env, not per-module sys.stdout reconfiguration
Test posture
10 scenarios / 102 assertions green on Mac. Live print of `→ ✓ ⚠ — em-dash` works.
Closes the silent-drop class filed earlier as #163.