Skip to content

fix: reconfigure stdout/stderr to UTF-8 on Windows to prevent charmap encoding errors#1385

Merged
cristipufu merged 1 commit intomainfrom
fix/cli_encoding_windows
Feb 27, 2026
Merged

fix: reconfigure stdout/stderr to UTF-8 on Windows to prevent charmap encoding errors#1385
cristipufu merged 1 commit intomainfrom
fix/cli_encoding_windows

Conversation

@cristipufu
Copy link
Member

@cristipufu cristipufu commented Feb 27, 2026

Summary

  • Fix 'charmap' codec can't encode character errors on Windows by reconfiguring stdout/stderr to UTF-8 early in CLI
    initialization
  • Windows console defaults to codepages (e.g. cp1252) that can't encode Unicode characters used by Rich spinners
    (Braille) and emoji output

Why this approach

Most popular Python CLIs (Rich, Click, pip) don't fix this themselves, they either document PYTHONUTF8=1 as a
user-side workaround, or avoid Unicode characters entirely.

Python 3.15 will make UTF-8 the default everywhere (https://peps.python.org/pep-0686/), but until then every Python
CLI on Windows is affected.

We chose sys.stdout.reconfigure(encoding="utf-8") over alternatives because:

  • PYTHONUTF8=1 can't be set programmatically: Python reads it at startup, so it would require users to configure it
    themselves
  • Avoiding Unicode characters limits UX (no spinners, no emoji)
  • reconfigure is scoped to stdout/stderr only, doesn't change behavior of open() or file system encoding, and is
    automatic for the user

Modern terminals (Windows Terminal, PowerShell 7, VS Code) already expect UTF-8, this fix just aligns Python's output
encoding with what they want. On legacy terminals, it prevents crashes (characters may render imperfectly but won't
throw exceptions).

@cristipufu cristipufu requested a review from Copilot February 27, 2026 04:12
@cristipufu cristipufu self-assigned this Feb 27, 2026
@github-actions github-actions bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository labels Feb 27, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Windows-specific encoding issue where the console's default codepage (e.g., cp1252) cannot handle Unicode characters used by Rich library components like Braille spinners and emoji output. The fix reconfigures stdout and stderr to UTF-8 encoding on Windows systems at CLI initialization time, before any heavy imports are loaded.

Changes:

  • Version bump from 2.9.14 to 2.9.15
  • Added Windows UTF-8 stream reconfiguration in CLI initialization

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
uv.lock Updated package version to 2.9.15
pyproject.toml Bumped version to 2.9.15
src/uipath/_cli/init.py Added Windows-specific UTF-8 encoding configuration for stdout/stderr to prevent charmap encoding errors with Unicode characters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cristipufu cristipufu changed the title fix: reconfigure stdout/stderr to UTF-8 on Windows to prevent charmap… fix: reconfigure stdout/stderr to UTF-8 on Windows to prevent charmap encoding errors Feb 27, 2026
@cristipufu cristipufu merged commit ce7a8a1 into main Feb 27, 2026
57 checks passed
@cristipufu cristipufu deleted the fix/cli_encoding_windows branch February 27, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants