Skip to content

fix(cli): avoid lint-translations UnicodeEncodeError on legacy consoles - #3006

Open
lntutor wants to merge 1 commit into
Chainlit:mainfrom
lntutor:fix/lint-translations-safe-output
Open

fix(cli): avoid lint-translations UnicodeEncodeError on legacy consoles#3006
lntutor wants to merge 1 commit into
Chainlit:mainfrom
lntutor:fix/lint-translations-safe-output

Conversation

@lntutor

@lntutor lntutor commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #2997

Summary

  • add a safe print helper for translation lint output
  • degrade emoji markers when stdout cannot encode them instead of crashing
  • cover both error and success paths with legacy cp1252 stdout regression tests

Verification

  • manual reproduction with cp1252-wrapped stdout no longer crashes
  • uv run --no-project pytest backend/tests/test_translations.py
  • uv run --no-project ruff check backend/chainlit/translations.py backend/tests/test_translations.py

Summary by cubic

Prevents the CLI translation linter from crashing on consoles that can’t encode emojis (e.g., cp1252). Output now degrades safely instead of raising UnicodeEncodeError.

  • Bug Fixes
    • Added _safe_print to handle unencodable characters based on sys.stdout.encoding.
    • Replaced direct print calls with _safe_print in lint output.
    • Added regression tests using a cp1252-wrapped stdout for both error and success paths.

Written for commit 76b4752. Summary will update on new commits.

Review in cubic

Co-Authored-By: Codex <codex@openai.com>
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working translation Translation or localisation of strings. unit-tests Has unit tests. labels Jul 31, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files. translation Translation or localisation of strings. unit-tests Has unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint-translations crashes with UnicodeEncodeError on a legacy Windows console code page

1 participant