Skip to content

Commit 6667cd4

Browse files
committed
[cli] ensure UTF-8 encoding when writing project files
1 parent 55759f6 commit 6667cd4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pywa/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def generate_code(target: str | None, is_async: bool, out_path: pathlib.Path) ->
337337
f"❌ Error: File '{out_file}' already exists. Aborting to prevent overwrite. Use --out to specify a different output directory or remove the existing file."
338338
)
339339
return
340-
out_file.write_text(code)
340+
out_file.write_text(code, encoding="utf-8")
341341
print(f"✅ Created new Pywa project at {out_file.resolve()}")
342342

343343

@@ -419,7 +419,9 @@ def download_example(
419419
dest_file = dest_dir / path[len(prefix) :]
420420
dest_file.parent.mkdir(parents=True, exist_ok=True)
421421
if path.endswith(".py") and not is_async:
422-
dest_file.write_text(async_code_to_sync(file_response.text))
422+
dest_file.write_text(
423+
async_code_to_sync(file_response.text), encoding="utf-8"
424+
)
423425
else:
424426
dest_file.write_bytes(file_response.content)
425427

0 commit comments

Comments
 (0)