fix: issue 1138 windows encoding (#1139)

* fix(windows): use utf-8 for text file operations

* fix(windows): normalize sandbox path masking

* fix(windows): preserve utf-8 handling after backend split
This commit is contained in:
-Astraia-
2026-03-16 16:53:12 +08:00
committed by GitHub
parent 76803b826f
commit 191b60a326
15 changed files with 116 additions and 24 deletions

View File

@@ -33,7 +33,7 @@ def generate_image(
output_file: str,
aspect_ratio: str = "16:9",
) -> str:
with open(prompt_file, "r") as f:
with open(prompt_file, "r", encoding="utf-8") as f:
prompt = f.read()
parts = []
i = 0

View File

@@ -24,7 +24,7 @@ def generate_ppt(
Status message
"""
# Load presentation plan
with open(plan_file, "r") as f:
with open(plan_file, "r", encoding="utf-8") as f:
plan = json.load(f)
# Determine slide dimensions based on aspect ratio

View File

@@ -87,7 +87,7 @@ def load_run_results(benchmark_dir: Path) -> dict:
metadata_path = eval_dir / "eval_metadata.json"
if metadata_path.exists():
try:
with open(metadata_path) as mf:
with open(metadata_path, encoding="utf-8") as mf:
eval_id = json.load(mf).get("eval_id", eval_idx)
except (json.JSONDecodeError, OSError):
eval_id = eval_idx
@@ -117,7 +117,7 @@ def load_run_results(benchmark_dir: Path) -> dict:
continue
try:
with open(grading_file) as f:
with open(grading_file, encoding="utf-8") as f:
grading = json.load(f)
except json.JSONDecodeError as e:
print(f"Warning: Invalid JSON in {grading_file}: {e}")
@@ -139,7 +139,7 @@ def load_run_results(benchmark_dir: Path) -> dict:
timing_file = run_dir / "timing.json"
if result["time_seconds"] == 0.0 and timing_file.exists():
try:
with open(timing_file) as tf:
with open(timing_file, encoding="utf-8") as tf:
timing_data = json.load(tf)
result["time_seconds"] = timing_data.get("total_duration_seconds", 0.0)
result["tokens"] = timing_data.get("total_tokens", 0)
@@ -374,13 +374,13 @@ def main():
output_md = output_json.with_suffix(".md")
# Write benchmark.json
with open(output_json, "w") as f:
with open(output_json, "w", encoding="utf-8") as f:
json.dump(benchmark, f, indent=2)
print(f"Generated: {output_json}")
# Write benchmark.md
markdown = generate_markdown(benchmark)
with open(output_md, "w") as f:
with open(output_md, "w", encoding="utf-8") as f:
f.write(markdown)
print(f"Generated: {output_md}")

View File

@@ -11,7 +11,7 @@ def generate_video(
output_file: str,
aspect_ratio: str = "16:9",
) -> str:
with open(prompt_file, "r") as f:
with open(prompt_file, "r", encoding="utf-8") as f:
prompt = f.read()
referenceImages = []
i = 0