Fix Windows encoding failure during project generation#84
Merged
Conversation
`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.
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.
Summary
Path.write_text/read_textinsrc/pipecat_cli/generators/project.pyrelied 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:9andtemplates/README.md.jinja2:3), sopipecat init quickstartfailed mid-generation with'charmap' codec can't encode character '→'and left a partial project directory.encoding="utf-8"to all 11 text I/O sites ingenerators/project.py(10 writes + 1 template read). No new abstraction — UTF-8 is named inline at each call site.test_generation_uses_utf8_on_windows_localethat monkeypatchesPath.write_text/read_textto simulate the Windows cp1252 fallback (data.encode("cp1252")raises on→), then runs the quickstart configuration end-to-end and asserts bothserver/bot.pyandREADME.mdwere written with the arrow intact.## [Unreleased]entry inCHANGELOG.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.UnicodeEncodeError: 'charmap' codec can't encode character '→' in position 182) whengenerators/project.pyis reverted — same failure mode as the issue report.uv run ruff checkanduv run ruff format --checkclean on touched files.🤖 Generated with Claude Code