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

@GopalGB
Copy link
Copy Markdown
Author

GopalGB commented Mar 31, 2026

@microsoft-github-policy-service agree

@GopalGB GopalGB force-pushed the fix/add-utf8-encoding-to-file-operations branch from d4eba66 to cb404ac Compare May 7, 2026 14:39
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

Signed-off-by: GopalGB <67310594+GopalGB@users.noreply.github.com>
@GopalGB GopalGB force-pushed the fix/add-utf8-encoding-to-file-operations branch from cb404ac to d9d03b7 Compare May 7, 2026 14:39
@GopalGB
Copy link
Copy Markdown
Author

GopalGB commented May 7, 2026

Rebased onto latest microsoft/autogen:main (was 37 days BEHIND) and re-authored under GopalGB <67310594+GopalGB@users.noreply.github.com> for consistent attribution. CI should now run on a fresh state. Ready for review when maintainers have cycles.

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