Skip to content

fix(encoding): PYTHONIOENCODING=utf-8 at airc startup (continuum's silent-drop catch) - #178

Merged
joelteply merged 1 commit into
canaryfrom
fix/airc-pythonio-utf8
Apr 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/airc-pythonio-utf8

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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

  • Per-module fix requires editing every airc_core module + future ones.
  • One env var covers every Python subprocess airc spawns.
  • Architectural shape per Joel's "always the best fix."

Test posture

10 scenarios / 102 assertions green on Mac. Live print of `→ ✓ ⚠ — em-dash` works.

Closes the silent-drop class filed earlier as #163.

…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.
Copilot AI review requested due to automatic review settings April 27, 2026 23:52
@joelteply
joelteply merged commit dee3b6c into canary Apr 27, 2026
1 check passed
@joelteply
joelteply deleted the fix/airc-pythonio-utf8 branch April 27, 2026 23:52
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