Skip to content

fix: add explicit encoding='utf-8' to text file operations#7499

Open
GopalGB wants to merge 1 commit intomicrosoft:mainfrom
GopalGB:fix/add-utf8-encoding-to-file-operations
Open

fix: add explicit encoding='utf-8' to text file operations#7499
GopalGB wants to merge 1 commit intomicrosoft:mainfrom
GopalGB:fix/add-utf8-encoding-to-file-operations

Conversation

@GopalGB
Copy link
Copy Markdown

@GopalGB GopalGB commented Mar 31, 2026

Summary

  • Adds encoding="utf-8" to all open() calls for text files across magentic-one-cli, autogen-studio, and agbench packages
  • Prevents UnicodeDecodeError on non-English Windows systems where Python defaults to the system locale encoding (e.g., cp1252, gbk)
  • 7 files updated, 24 open() calls fixed

Files Changed

  • magentic-one-cli/src/magentic_one_cli/_m1.py — config file reads
  • autogen-studio/autogenstudio/database/schema_manager.py — Alembic config/template reads and writes
  • agbench/src/agbench/run_cmd.py — scenario files, env configs, run scripts
  • agbench/src/agbench/tabulate_cmd.py — console log reads
  • agbench/src/agbench/remove_missing_cmd.py — console log reads
  • agbench/src/agbench/linter/cli.py — log file reads
  • agbench/src/agbench/linter/coders/oai_coder.py — cache file reads/writes

Test Plan

  • All changes are mechanical: adding encoding="utf-8" parameter only
  • No behavioral change on systems where UTF-8 is already the default
  • Fixes crashes on Windows with non-English locale (e.g., Chinese, Japanese, Korean)

Fixes #5566

On non-English Windows systems, Python's open() defaults to the
system locale encoding (e.g. cp1252, gbk) rather than UTF-8, causing
UnicodeDecodeError when reading config files, logs, or templates
containing non-ASCII characters.

Adds encoding='utf-8' to all open() calls across magentic-one-cli,
autogen-studio, and agbench packages.

Fixes microsoft#5566
@GopalGB
Copy link
Copy Markdown
Author

GopalGB commented Mar 31, 2026

@microsoft-github-policy-service agree

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.

open needs encoding='utf-8' for non-english environment, error in playwright_controller.py

1 participant