Add explicit UTF-8 encoding to file operations in autogen-ext#7400
Open
alpnix wants to merge 1 commit intomicrosoft:mainfrom
Open
Add explicit UTF-8 encoding to file operations in autogen-ext#7400alpnix wants to merge 1 commit intomicrosoft:mainfrom
alpnix wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes microsoft#5566 by adding encoding='utf-8' parameter to all text-mode file operations that were missing it. This prevents UnicodeDecodeError on Windows systems with non-English system locales. Changes made: - docker_jupyter/_docker_jupyter.py: HTML file writing - page_logger.py: Hash file, call tree HTML, and page HTML writing - chat_completion_client_recorder.py: JSON session file read/write This follows Python 3 best practices (PEP 597) and ensures cross-platform compatibility for international users. All changes are mechanical additions of encoding parameter with no functional changes to the code logic.
Author
|
@microsoft-github-policy-service agree |
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
Fixes #5566 by adding
encoding='utf-8'parameter to text-mode file operations that were missing it in the autogen-ext package. This preventsUnicodeDecodeErroron Windows systems with non-English system locales.Problem
The codebase had multiple
open()calls without explicit UTF-8 encoding, causing crashes on Windows with non-English locales (Chinese, Japanese, etc.). While one instance was previously fixed inplaywright_controller.py, several others remained throughout the codebase.Changes
Added
encoding="utf-8"to 6 file operations across 3 files:1.
code_executors/docker_jupyter/_docker_jupyter.py_save_htmlmethod2.
experimental/task_centric_memory/utils/page_logger.py3.
experimental/task_centric_memory/utils/chat_completion_client_recorder.pyTesting
Impact
High - Prevents crashes for international users on Windows systems with non-English locales, improving cross-platform compatibility.
Diff Summary
All changes follow the same pattern:
Closes #5566