fix(benchmarks): UTF-8 encoding + ASCII print chrome on Windows for the 3 sibling runners - #1382
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the three benchmark runner scripts (locomo, membench, convomem) for native Windows execution by making local JSON file I/O explicitly UTF-8 and replacing non-ASCII console separators/arrows that can trigger UnicodeEncodeError on default cp1252 terminals.
Changes:
- Add
encoding="utf-8"to localopen(...)calls used for reading/writing JSON caches and results in the three runners. - Replace non-ASCII console “chrome” characters (
─,→) used inprint(...)output with ASCII-safe equivalents (-,->).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| benchmarks/membench_bench.py | Explicit UTF-8 for JSON file read/write; ASCII-only separator output. |
| benchmarks/locomo_bench.py | Explicit UTF-8 for dataset/cache/results I/O; ASCII-only separator and progress output. |
| benchmarks/convomem_bench.py | Explicit UTF-8 for cache/result JSON I/O; ASCII-only separator output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
736037c to
ea63b28
Compare
… Windows Follow-up to MemPalace#1204 per @mschultheiss83's request — applies the same narrow Windows encoding fix to the three remaining LongMemEval-shaped benchmark runners that share the audit pattern jphein flagged in MemPalace#1204's review (`benchmarks/{locomo,membench,convomem}_bench.py`). For each file: - All `open(path)` / `open(path, "w")` calls gained `encoding="utf-8"` so cached benchmark JSON, palace-cache files, and result files are always read/written as UTF-8 instead of inheriting the platform default (cp1252 on Windows, GBK on Chinese Windows, etc.). Same pattern as MemPalace#1204's #2917 / #2927 / #2957 / #2998 / #3031. - Replaced non-ASCII separator characters in `print(...)` chrome with ASCII equivalents (`─` → `-`, `→` → `->`) so the runners don't raise `UnicodeEncodeError` on a default cp1252 console. Comments and docstrings (which never hit stdout) are untouched. - `urllib.request.urlopen(...)` calls left alone — they don't open local files, the original audit didn't flag them. Audit was already done in MemPalace#1204's thread; this PR carries the mechanical follow-through. No behavior change beyond Windows correctness. Refs MemPalace#1203 (the original Windows reproducer), MemPalace#1204 (sibling PR that fixed `longmemeval_bench.py`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ea63b28 to
91d81d5
Compare
|
@bensig @milla-jovovich please review... |
|
Trivial Windows fix: adds explicit |
Summary
Follow-up to #1204 (LongMemEval Windows encoding) per @mschultheiss83's request. Applies the same narrow Windows correctness pattern to the three sibling benchmark runners that share the same shape:
benchmarks/locomo_bench.pybenchmarks/membench_bench.pybenchmarks/convomem_bench.pyWhat changed (per file)
open(path)/open(path, "w")calls now passencoding="utf-8"(was inheriting the platform default —cp1252on Windows,GBKon Chinese Windows). Mirrors benchmarks: harden longmemeval runner for Windows encoding #1204's pattern atlongmemeval_bench.py:2917 / :2927 / :2957 / :2998 / :3031.print(...)chrome replaced with ASCII (─→-,→→->) so a defaultcp1252console doesn't raiseUnicodeEncodeErrormid-run. Comments/docstrings (which never hit stdout) are untouched.urllib.request.urlopen(...)calls intentionally left alone — they don't open local files, and the original benchmarks: harden longmemeval runner for Windows encoding #1204 audit didn't flag them.Total diff: +16 / -16 across 3 files. No behavior change beyond Windows correctness.
Audit provenance
The file selection isn't speculative — jphein already audited the codebase in #1204's review thread and flagged the exact
open(...)lines in these three files. @mschultheiss83 asked for the follow-up at #1204 (comment). This PR is just the mechanical follow-through.Out of scope
C901ruff finding onlocomo_bench.py:621(run_benchmarkcomplexity 36) is from upstreamdevelop(verified by stash + re-lint on stock branch); not from this PR.Test plan
--cache-dirarguments don't regress🤖 Generated with Claude Code