fix: add encoding='utf-8' to open() calls in autogen-ext#7257
Open
ddarji1409 wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: add encoding='utf-8' to open() calls in autogen-ext#7257ddarji1409 wants to merge 1 commit intomicrosoft:mainfrom
ddarji1409 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes UnicodeDecodeError on non-UTF-8 systems (e.g. Windows with cp950/cp932) by explicitly specifying encoding='utf-8' on all text-mode open() calls in the autogen-ext package. Fixes microsoft#5566 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
@ddarji1409 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
anandfresh
approved these changes
Feb 24, 2026
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
UnicodeDecodeErroron systems with non-UTF-8 default encodings (e.g. Windows with cp950, cp932, or other CJK codecs) by explicitly specifyingencoding='utf-8'on all text-modeopen()calls in theautogen-extpackage.Closes #5566
Files changed
autogen_ext/code_executors/docker_jupyter/_docker_jupyter.py—_save_html()writeautogen_ext/experimental/task_centric_memory/utils/chat_completion_client_recorder.py— session file read & writeautogen_ext/experimental/task_centric_memory/utils/page_logger.py— hash, call-tree, and page HTML writesRoot cause
Python's
open()defaults to the platform locale encoding (locale.getpreferredencoding()). On East Asian Windows systems this is oftencp950orcp932, which cannot decode the UTF-8 encoded content written by other parts of the codebase (e.g.page_script.jswhich already had the fix applied). Explicitly passingencoding='utf-8'makes behaviour consistent across all platforms.Test plan
PYTHONIOENCODING=cp950) and confirm the error is gonepytest python/packages/autogen-ext/tests/🤖 Generated with Claude Code