Skip to content

Commit e2ad9b5

Browse files
committed
fix(uts-skill): make resolve_uts.py file I/O Windows-safe
read_text()/write_text() default to the locale encoding on Windows (often cp1252, not UTF-8) and apply newline translation, which would both mis-handle non-ASCII content and rewrite the git-tracked uts-package-mapping.json with CRLF. Pin the read to utf-8 and write via write_bytes (binary mode does zero newline translation on any OS or Python version, keeping the file LF — unlike write_text(newline=...), which needs Python 3.10+). Aligns with the utf-8 reads already in audit_translation.py.
1 parent 0834c45 commit e2ad9b5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.claude/skills/uts-to-kotlin/scripts/resolve_uts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def main():
112112

113113
if not MAPPING.is_file():
114114
fail("MAPPING_NOT_FOUND", f"mapping file not found at {MAPPING}")
115-
data = json.loads(MAPPING.read_text())
115+
data = json.loads(MAPPING.read_text(encoding="utf-8"))
116116
packages = data.setdefault("packages", {})
117117
test_root = data.get("testRoot", "")
118118

@@ -133,7 +133,10 @@ def main():
133133
if notes:
134134
new_entry["notes"] = notes
135135
packages[source_module] = new_entry
136-
MAPPING.write_text(json.dumps(data, indent=2) + "\n")
136+
# Write bytes (not write_text): explicit utf-8, and binary mode does zero newline
137+
# translation on any OS or Python version — so this git-tracked file stays LF on
138+
# Windows too. (write_text(newline=...) would need Python 3.10+.)
139+
MAPPING.write_bytes((json.dumps(data, indent=2) + "\n").encode("utf-8"))
137140

138141
mapped = source_module in packages
139142
entry = packages.get(source_module, {})

0 commit comments

Comments
 (0)