Skip to content

Commit

Permalink
Merge pull request #202 from xen0n/utf8-for-text-file-io
Browse files Browse the repository at this point in the history
fix: explicitly specify utf-8 for text file I/O
  • Loading branch information
xen0n authored Sep 24, 2024
2 parents c2384a9 + 91a2fa1 commit 97b0838
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ruyi/config/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def __init__(self, path: str) -> None:

def load(self) -> None:
try:
with open(self._path, "r") as fp:
with open(self._path, "r", encoding="utf-8") as fp:
for line in fp:
self._orig_status.add(line.strip())
except FileNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion ruyi/mux/venv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def main() -> None:
os.chdir(self_path)

payloads = {f[:-6]: make_payload_from_file(f) for f in glob.iglob("*.jinja")}
with open("data.py", "w") as fp:
with open("data.py", "w", encoding="utf-8") as fp:

def p(*args: Any) -> None:
return print(*args, file=fp)
Expand Down
2 changes: 1 addition & 1 deletion ruyi/ruyipkg/admin_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def cli_admin_format_manifest(args: argparse.Namespace) -> int:
d = dump_canonical_package_manifest_toml(pm.to_raw())

dest_path = p.with_suffix(".toml")
with open(dest_path, "w") as fp:
with open(dest_path, "w", encoding="utf-8") as fp:
fp.write(_fix_indent(d.as_string()))

return 0
Expand Down
2 changes: 1 addition & 1 deletion ruyi/ruyipkg/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def ensure_provisioner_config_cache(self) -> None:
parsed_config: ProvisionerConfig | None = None
for filename in ("config.yml", "config.yaml"):
try:
with open(os.path.join(cfg_dir, filename), "r") as fp:
with open(os.path.join(cfg_dir, filename), "r", encoding="utf-8") as fp:
parsed_config = yaml.safe_load(fp)
break
except FileNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion scripts/dist-inner.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def set_gha_output(k: str, v: str) -> None:
return

INFO.print(f"GHA: setting output [cyan]{k}[/] to [cyan]{v}[/]")
with open(outfile, "a") as fp:
with open(outfile, "a", encoding="utf-8") as fp:
fp.write(f"{k}={v}\n")


Expand Down

0 comments on commit 97b0838

Please sign in to comment.