fix: add explicit UTF-8 encoding to read_text() calls (#776)#946
Merged
igorls merged 1 commit intoMemPalace:developfrom Apr 16, 2026
Merged
fix: add explicit UTF-8 encoding to read_text() calls (#776)#946igorls merged 1 commit intoMemPalace:developfrom
igorls merged 1 commit intoMemPalace:developfrom
Conversation
On Windows with non-UTF-8 locale (e.g. GBK), Path.read_text() defaults to platform encoding, breaking onboarding tests and any source code that reads JSON/markdown with non-ASCII content. 5 files, 8 call sites fixed.
igorls
added a commit
that referenced
this pull request
Apr 16, 2026
Bumps version across pyproject.toml, mempalace/version.py, README badge, and uv.lock. Finalizes the 3.3.0 CHANGELOG section (was still labeled 'Unreleased') and adds a 3.3.1 section covering the multi-language entity-detection infra and the five new locales landed since 2026-04-13. Highlights: - Multi-language entity detection infra (#911) + script-aware word boundaries for combining-mark scripts (#932) + BCP 47 case-insensitive locale resolution (#928) + i18n patterns wired into miner/palace/ entity_registry (#931) - Five new fully-supported locales: pt-br (#156), ru (#760), it (#907), hi (#773), id (#778) - UTF-8 encoding fix on read_text() calls for non-UTF-8 Windows locales (#946) - KnowledgeGraph lock correctness (#884, #887) - Various smaller fixes and improvements
shafdev
pushed a commit
to shafdev/mempalace
that referenced
this pull request
Apr 17, 2026
Bumps version across pyproject.toml, mempalace/version.py, README badge, and uv.lock. Finalizes the 3.3.0 CHANGELOG section (was still labeled 'Unreleased') and adds a 3.3.1 section covering the multi-language entity-detection infra and the five new locales landed since 2026-04-13. Highlights: - Multi-language entity detection infra (MemPalace#911) + script-aware word boundaries for combining-mark scripts (MemPalace#932) + BCP 47 case-insensitive locale resolution (MemPalace#928) + i18n patterns wired into miner/palace/ entity_registry (MemPalace#931) - Five new fully-supported locales: pt-br (MemPalace#156), ru (MemPalace#760), it (MemPalace#907), hi (MemPalace#773), id (MemPalace#778) - UTF-8 encoding fix on read_text() calls for non-UTF-8 Windows locales (MemPalace#946) - KnowledgeGraph lock correctness (MemPalace#884, MemPalace#887) - Various smaller fixes and improvements
jphein
added a commit
to jphein/mempalace
that referenced
this pull request
Apr 18, 2026
Upstream v3.3.1 headline: multi-language entity detection (PT-BR, Russian, Italian, Hindi, Indonesian, Chinese), BCP-47 case-insensitive locale resolution, UTF-8 encoding fix for non-UTF-8 Windows locales, combining-mark word-boundary fix for Devanagari/Arabic/Hebrew/Thai scripts. Also absorbs PR MemPalace#966 (honor silent_save), MemPalace#863 (precompact blocking fix), MemPalace#895/MemPalace#897 (benchmarks + README rewrite), MemPalace#946 (UTF-8 Path.read_text), and more. Conflict resolutions: - mempalace/hooks_cli.py: kept fork-only _desktop_toast + _mempalace_python (hook wrappers depend on these), adopted upstream's _get_mine_dir helper + _mine_sync function + _maybe_auto_ingest(transcript_path) signature, kept fork's silent-save MempalaceConfig branch, kept _ingest_transcript call in hook_precompact before the new _mine_sync so the session JSONL still gets captured on precompact. - tests/test_hooks_cli.py: merged both import sets. Updated test_stop_hook_rejects_injected_stop_hook_active to accept either the silent-save systemMessage output or the legacy decision=block — the security property (don't treat injected stop_hook_active as truthy) holds for both modes. - tests/test_miner.py: merged both import sets (CHUNK_* constants + load_config). - tests/test_readme_claims.py: accepted upstream's shift from README parsing to website/reference/mcp-tools.md and modules.md — website docs are now the source of truth for the tool table. - mempalace/entity_detector.py: accepted upstream wholesale — replaces hardcoded English STOPWORDS with i18n-JSON-backed patterns and backward- compat module constants. - README.md: kept fork README, bumped version badge 3.3.0 → 3.3.1. Verification: 995 tests pass, stop hook fires end-to-end ("✦ 13 memories woven into the palace"), 10/10 fresh-process palace opens + queries OK. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks
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.
What
Path.read_text()withoutencodingdefaults to platform encoding on Windows. On locales like GBK this breaks any file written as UTF-8.8 call sites fixed across 5 files:
Why explicit encoding, not PYTHONUTF8
Considered alternatives:
PYTHONUTF8=1in CI -- must be set before Python starts, so it can't go in conftest.py. Works for CI but doesn't fix local test runs on Windows. Also a global override of all I/O which can mask real encoding bugs.encoding="utf-8"per call -- PEP 597 recommendation. Works on all Python versions, all platforms, no env setup needed.Test plan
pytest tests/test_onboarding.py tests/test_instructions_cli.py -v-- 52 passed locally