Skip to content

handle windows char encoding errors - #28

Merged
jbouder merged 3 commits into
mainfrom
dpr-pipe-fix
May 7, 2026
Merged

jbouder merged 3 commits into
mainfrom
dpr-pipe-fix

Conversation

@dillonroach

Copy link
Copy Markdown
Contributor
  • serve.py:9-13 - reconfigure sys.stdout/sys.stderr to UTF-8 with errors='replace' on Windows.
  • serve.py:117-119 - Popen in run_with_pipes now decodes child output as UTF-8 explicitly with errors='replace', instead of inheriting the locale codec (cp1252).
  • serve.py:161-162 - pass PYTHONIOENCODING=utf-8 and PYTHONUTF8=1 to subprocesses, so any spawned Python (e.g. hf CLI) emits UTF-8 instead of the legacy code page.
  • app.py:13-17 - same Windows stdout/stderr reconfigure for safety.

The root cause was the hf CLI emitting ✓ (U+2713) status glyphs; subprocess.Popen(text=True, ...) without an explicit encoding= defaulted to Windows' cp1252, and re-encoding via print() then raised the charmap error. Forcing UTF-8 on both sides fixes it without changing behavior on Linux/macOS.

@dillonroach
dillonroach requested a review from jbouder May 5, 2026 22:49
@dillonroach dillonroach added the bug Something isn't working label May 5, 2026
@jbouder
jbouder merged commit 0f48793 into main May 7, 2026
1 check passed
@jbouder
jbouder deleted the dpr-pipe-fix branch May 7, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants