From 15bf226c84d00ba51537a8ba136e17018572a071 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Sun, 24 Sep 2023 12:31:38 +0200 Subject: [PATCH] Consistency: use `utf-8` encoding name everywhere In fact, Python codec is `utf_8` but it has aliases, `utf8' (declared as alias) or `utf-8` (because `_` or `-` do not make difference) are working, but we mainly use `utf-8` among the code. See https://docs.python.org/3/library/codecs.html#standard-encodings --- picard/script/serializer.py | 4 ++-- picard/tagger.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/picard/script/serializer.py b/picard/script/serializer.py index a3e8413e54..e073aabc94 100644 --- a/picard/script/serializer.py +++ b/picard/script/serializer.py @@ -222,7 +222,7 @@ def export_script(self, parent=None): else: script_text = self.script + "\n" try: - with open(filename, 'w', encoding='utf8') as o_file: + with open(filename, 'w', encoding='utf-8') as o_file: o_file.write(script_text) except OSError as error: raise ScriptImportExportError(format=FILE_ERROR_EXPORT, filename=filename, error_msg=error.strerror) @@ -252,7 +252,7 @@ def import_script(cls, parent=None): return None log.debug("Importing script file: %s", filename) try: - with open(filename, 'r', encoding='utf8') as i_file: + with open(filename, 'r', encoding='utf-8') as i_file: file_content = i_file.read() except OSError as error: raise ScriptImportExportError(format=FILE_ERROR_IMPORT, filename=filename, error_msg=error.strerror) diff --git a/picard/tagger.py b/picard/tagger.py index 6e1b62d8a5..ff4c852e93 100644 --- a/picard/tagger.py +++ b/picard/tagger.py @@ -615,7 +615,7 @@ def handle_command_submit_fingerprints(self, argstring): def handle_command_write_logs(self, argstring): try: - with open(argstring, 'w', encoding='utf8') as f: + with open(argstring, 'w', encoding='utf-8') as f: for x in self.window.log_dialog.log_tail.contents(): f.write(f"{x.message}\n") except Exception as e: @@ -1533,7 +1533,7 @@ def main(localedir=None, autoupdate=True): identifier = uuid4().hex else: if picard_args.config_file: - identifier = blake2b(picard_args.config_file.encode('utf8'), digest_size=16).hexdigest() + identifier = blake2b(picard_args.config_file.encode('utf-8'), digest_size=16).hexdigest() else: identifier = 'main' if picard_args.no_plugins: