Skip to content

Commit

Permalink
Explicitly specify encoding when opening text files
Browse files Browse the repository at this point in the history
  • Loading branch information
Acly committed Sep 7, 2024
1 parent d338075 commit dd8ddd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ai_diffusion/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Language(NamedTuple):
@staticmethod
def from_file(filepath: Path):
try:
with filepath.open() as f:
with filepath.open(encoding="utf-8") as f:
lang = json.load(f)
return Language(lang["id"], lang["name"], filepath)
except Exception as e:
Expand Down Expand Up @@ -51,7 +51,7 @@ def id(self):
@staticmethod
def load(id: str, filepath: Path):
try:
with filepath.open() as f:
with filepath.open(encoding="utf-8") as f:
lang = json.load(f)
return Localization(id, lang["name"], lang["translations"])
except Exception as e:
Expand All @@ -63,7 +63,7 @@ def init(settings_path: Path | None = None):
settings_path = settings_path or user_data_dir / "settings.json"
if settings_path.exists():
try:
with settings_path.open() as f:
with settings_path.open(encoding="utf-8") as f:
settings = json.load(f)
language = settings.get("language", "en")
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def main():

version_file = server_dir / ".version"
assert version_file.exists()
with version_file.open("w") as f:
with version_file.open("w", encoding="utf-8") as f:
f.write("1.0.42")
server.check_install()
assert server.upgrade_required
Expand Down

0 comments on commit dd8ddd7

Please sign in to comment.