From 452d72e5e2f048c3004119d68a8ff6c6c8fdd4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Snoksrud?= Date: Fri, 5 Jun 2026 14:57:29 +0200 Subject: [PATCH] sync: pin tree dump/load file IO to UTF-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Path.read_text()/write_text() default to the locale encoding, so `novem --dump`/`--load` could silently mojibake non-ASCII content (em-dashes, å, …) under a non-UTF-8 locale (e.g. LANG=C). Pin both ends to utf-8 so the on-disk tree format is canonical regardless of locale. --- novem/sync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/novem/sync.py b/novem/sync.py index 482aaf3..64eba9a 100644 --- a/novem/sync.py +++ b/novem/sync.py @@ -52,7 +52,7 @@ def write_file(api_path: str, content: str) -> None: if not fp.parent.exists(): fp.parent.mkdir(parents=True, exist_ok=True) print(f"Creating folder: {fp.parent}") - fp.write_text(content) + fp.write_text(content, encoding="utf-8") print(f"Writing file: {fp}") def rec_tree(path: str) -> None: @@ -107,7 +107,7 @@ def walk(full: Path, api_path: str) -> None: return if full.is_file(): - files[api_path] = full.read_text() + files[api_path] = full.read_text(encoding="utf-8") elif full.is_dir(): for name in sorted(p.name for p in full.iterdir()): walk(full / name, f"{api_path}/{name}")