Skip to content

fix: add encoding=utf-8 to open() calls in task_centric_memory utils#7897

Open
Lakshmi786 wants to merge 1 commit into
microsoft:mainfrom
Lakshmi786:fix/utf8-encoding-task-centric-memory
Open

fix: add encoding=utf-8 to open() calls in task_centric_memory utils#7897
Lakshmi786 wants to merge 1 commit into
microsoft:mainfrom
Lakshmi786:fix/utf8-encoding-task-centric-memory

Conversation

@Lakshmi786

Copy link
Copy Markdown

Summary

Text-mode open() calls without an explicit encoding fall back to the platform locale, which is not UTF-8 on Windows with non-English system locales. This causes UnicodeDecodeError / UnicodeEncodeError when session files or HTML log pages contain non-ASCII characters.

Files fixed

  • chat_completion_client_recorder.py — read + write of JSON session file
  • page_logger.py — write of hash.txt, call-tree HTML, and page HTML

Fixes #5566

Text-mode open() without an explicit encoding falls back to the
platform locale, which is not UTF-8 on Windows with non-English
system locales. This causes UnicodeDecodeError / UnicodeEncodeError
when session files or log HTML pages contain non-ASCII characters.

Affected files:
- chat_completion_client_recorder.py  (read + write of JSON session)
- page_logger.py  (write of hash.txt, call-tree HTML, page HTML)

Closes microsoft#5566
@Lakshmi786

Copy link
Copy Markdown
Author

Hi,

Fixing issue #5566. Text-mode open() calls without an explicit encoding fall back to the platform locale, which is not UTF-8 on Windows with non-English system locales. This causes UnicodeDecodeError or UnicodeEncodeError when session files or HTML log pages contain non-ASCII content.

Fixed five open() calls across two files in task_centric_memory:

  • chat_completion_client_recorder.py: read and write of the JSON session file
  • page_logger.py: write of hash.txt, the call-tree HTML, and each page HTML file

The playwright_controller.py file was already correctly using encoding=utf-8.

@Lakshmi786

Copy link
Copy Markdown
Author

@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