Skip to content

Fix Windows encoding failure during project generation#84

Merged
markbackman merged 2 commits into
mainfrom
mb/fix-utf-encoding
May 19, 2026
Merged

Fix Windows encoding failure during project generation#84
markbackman merged 2 commits into
mainfrom
mb/fix-utf-encoding

Conversation

@markbackman
Copy link
Copy Markdown
Contributor

Summary

  • Path.write_text / read_text in src/pipecat_cli/generators/project.py relied on the platform default encoding. On Windows that is cp1252, which cannot encode the characters in cascade-mode templates (templates/server/bot_cascade.py.jinja2:9 and templates/README.md.jinja2:3), so pipecat init quickstart failed mid-generation with 'charmap' codec can't encode character '→' and left a partial project directory.
  • Added encoding="utf-8" to all 11 text I/O sites in generators/project.py (10 writes + 1 template read). No new abstraction — UTF-8 is named inline at each call site.
  • Added a regression test test_generation_uses_utf8_on_windows_locale that monkeypatches Path.write_text / read_text to simulate the Windows cp1252 fallback (data.encode("cp1252") raises on ), then runs the quickstart configuration end-to-end and asserts both server/bot.py and README.md were written with the arrow intact.
  • Added an ## [Unreleased] entry in CHANGELOG.md.

Fixes pipecat-ai/pipecat#4523.

Test plan

  • uv run pytest tests/test_project_generation.py tests/test_quickstart.py tests/test_client_generation.py — 49 passed.
  • New regression test passes with the fix and fails (UnicodeEncodeError: 'charmap' codec can't encode character '→' in position 182) when generators/project.py is reverted — same failure mode as the issue report.
  • uv run ruff check and uv run ruff format --check clean on touched files.
  • Manual confirmation on a real Windows host (no Windows VM available locally; the monkeypatch reproduces the failure faithfully on macOS).

🤖 Generated with Claude Code

`Path.write_text` / `read_text` calls in `generators/project.py`
relied on the platform default encoding. On Windows that is cp1252,
which cannot encode the `→` character present in cascade-mode
templates (`bot_cascade.py.jinja2`, `README.md.jinja2`), causing
`pipecat init quickstart` to fail mid-generation and leave a partial
project directory. Pass `encoding="utf-8"` explicitly at every text
I/O site, and add a regression test that simulates the Windows
locale by monkeypatching the Path methods to fail when `encoding` is
omitted.

Fixes pipecat-ai/pipecat#4523.
@markbackman markbackman merged commit 1b2f698 into main May 19, 2026
1 check passed
@markbackman markbackman deleted the mb/fix-utf-encoding branch May 19, 2026 22:50
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.

Unable to create a project

1 participant