From 5d3c0cc6ec93c52c8f9c6afafbfdaad55cd647fc Mon Sep 17 00:00:00 2001 From: benex Date: Sun, 15 Sep 2024 14:38:50 +0300 Subject: [PATCH] fix: unicode error on windows when writing the config file --- fastanime/cli/commands/config.py | 4 ++-- fastanime/cli/config.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fastanime/cli/commands/config.py b/fastanime/cli/commands/config.py index 75f2d9f..847abde 100644 --- a/fastanime/cli/commands/config.py +++ b/fastanime/cli/commands/config.py @@ -94,8 +94,8 @@ def config(user_config: "Config", path, view, desktop_entry, update): print(f"Successfully wrote \n{f.read()}") exit_app(0) elif update: - with open(USER_CONFIG_PATH, "w") as file: - file.write(user_config.__repr__()) + with open(USER_CONFIG_PATH, "w",encoding="utf-8") as file: + file.write(user_config.__str__()) print("update successfull") else: click.edit(filename=USER_CONFIG_PATH) diff --git a/fastanime/cli/config.py b/fastanime/cli/config.py index 60ba621..0141b5e 100644 --- a/fastanime/cli/config.py +++ b/fastanime/cli/config.py @@ -64,7 +64,7 @@ class Config(object): # --- set config values from file or using defaults --- if os.path.exists(USER_CONFIG_PATH): - self.configparser.read(USER_CONFIG_PATH) + self.configparser.read(USER_CONFIG_PATH,encoding="utf-8") self.downloads_dir = self.get_downloads_dir() self.sub_lang = self.get_sub_lang() @@ -103,7 +103,7 @@ class Config(object): os.environ["CURRENT_FASTANIME_PROVIDER"] = self.provider if not os.path.exists(USER_CONFIG_PATH): - with open(USER_CONFIG_PATH, "w") as config: + with open(USER_CONFIG_PATH, "w",encoding="utf-8") as config: config.write(self.__repr__()) def update_user(self, user):