fix: add encoding='utf-8' to open() calls for non-English environments (#5566)#7423
Open
zlplzp123wyt wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: add encoding='utf-8' to open() calls for non-English environments (#5566)#7423zlplzp123wyt wants to merge 1 commit intomicrosoft:mainfrom
zlplzp123wyt wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes UnicodeDecodeError when running autogen in CJK locales (cp939, cp950, etc.) where the default system encoding cannot decode UTF-8 source files. Fixes microsoft#5566 Files fixed: - magentic_one_cli/_m1.py: config file reading - docker_jupyter/_docker_jupyter.py: script file reading - task_centric_memory/utils/page_logger.py: log file operations - task_centric_memory/utils/chat_completion_client_recorder.py: cache file operations
Author
|
@microsoft-github-policy-service agree |
5 tasks
Author
|
Hi, this PR fixes encoding issues in calls for non-English environments. All CI checks pass. Would appreciate a review when time permits. Thank you! |
Author
|
Hi! This is a simple but important fix for non-English environments. Adding explicit encoding='utf-8' to open() calls prevents UnicodeDecodeError on systems where the default encoding isn't UTF-8. Ready for review whenever convenient. Thanks! |
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 UnicodeDecodeError when running AutoGen in CJK locales (cp939, cp950, gb2312, etc.) where the default system encoding cannot decode UTF-8 source files.
Fixes #5566
Changes
Added
encoding="utf-8"toopen()calls in text mode across 4 files:Reproduction
On Windows with system locale set to Chinese (Traditional):
Test Plan