Skip to content

Commit 3b0732f

Browse files
committed
fix: ensure utf-8 encoding is used in all relevant open() calls
1 parent 13e144e commit 3b0732f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

python/packages/autogen-ext/src/autogen_ext/code_executors/docker_jupyter/_docker_jupyter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _save_html(self, html_data: str) -> str:
275275
"""Save html data to a file."""
276276
filename = f"{uuid.uuid4().hex}.html"
277277
path = os.path.join(str(self._output_dir), filename)
278-
with open(path, "w") as f:
278+
with open(path, "w", encoding="utf-8") as f:
279279
f.write(html_data)
280280
return os.path.abspath(path)
281281

python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/chat_completion_client_recorder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
# Load the previously recorded messages and responses from disk.
7474
self.logger.info("Replay mode enabled.\nRetrieving session from: " + self.session_file_path)
7575
try:
76-
with open(self.session_file_path, "r") as f:
76+
with open(self.session_file_path, "r", encoding="utf-8") as f:
7777
self.records = json.load(f)
7878
except Exception as e:
7979
error_str = f"\nFailed to load recorded session: '{self.session_file_path}': {e}"
@@ -211,7 +211,7 @@ def finalize(self) -> None:
211211
# Create the directory if it doesn't exist.
212212
os.makedirs(os.path.dirname(self.session_file_path), exist_ok=True)
213213
# Write the records to disk.
214-
with open(self.session_file_path, "w") as f:
214+
with open(self.session_file_path, "w", encoding="utf-8") as f:
215215
json.dump(self.records, f, indent=2)
216216
self.logger.info("\nRecorded session was saved to: " + self.session_file_path)
217217
except Exception as e:

python/packages/magentic-one-cli/src/magentic_one_cli/_m1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ def main() -> None:
9797

9898
if args.config is None:
9999
if os.path.isfile(DEFAULT_CONFIG_FILE):
100-
with open(DEFAULT_CONFIG_FILE, "r") as f:
100+
with open(DEFAULT_CONFIG_FILE, "r", encoding="utf-8") as f:
101101
config = yaml.safe_load(f)
102102
else:
103103
config = yaml.safe_load(DEFAULT_CONFIG_CONTENTS)
104104
else:
105-
with open(args.config if isinstance(args.config, str) else args.config[0], "r") as f:
105+
with open(args.config if isinstance(args.config, str) else args.config[0], "r", encoding="utf-8") as f:
106106
config = yaml.safe_load(f)
107107

108108
# Run the task

0 commit comments

Comments
 (0)