Specify 'utf-8' encoding when opening temp file. (#22)

This commit is contained in:
Posi+ive
2025-10-06 06:42:21 +08:00
committed by GitHub
parent 4cec942613
commit e9ba78cec3

View File

@@ -294,7 +294,7 @@ def _apply_tags(path: Path, tags: dict[str, str]) -> None:
for name, value in tags.items(): for name, value in tags.items():
xml_lines.append(f" <Simple><Name>{escape(name)}</Name><String>{escape(value)}</String></Simple>") xml_lines.append(f" <Simple><Name>{escape(name)}</Name><String>{escape(value)}</String></Simple>")
xml_lines.extend([" </Tag>", "</Tags>"]) xml_lines.extend([" </Tag>", "</Tags>"])
with tempfile.NamedTemporaryFile("w", suffix=".xml", delete=False) as f: with tempfile.NamedTemporaryFile("w", suffix=".xml", delete=False, encoding="utf-8") as f:
f.write("\n".join(xml_lines)) f.write("\n".join(xml_lines))
tmp_path = Path(f.name) tmp_path = Path(f.name)
try: try: