From 75a5255806b5607bbc714d56a5b6aea7f76062fc Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Sat, 1 Jul 2023 18:14:10 +0200 Subject: [PATCH] Sepcified utf-8 for lzma log backups --- src/logging/session_file_handler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/logging/session_file_handler.py b/src/logging/session_file_handler.py index ac0c199..bc6e06e 100644 --- a/src/logging/session_file_handler.py +++ b/src/logging/session_file_handler.py @@ -88,16 +88,20 @@ class SessionFileHandler(StreamHandler): # If uncompressed, compress if not path.name.endswith(".xz"): - new_path = path.with_suffix(path.suffix + ".xz") + compressed_path = path.with_suffix(path.suffix + ".xz") with ( lzma.open( - new_path, "wt", format=FORMAT_XZ, preset=PRESET_DEFAULT + compressed_path, + "wt", + format=FORMAT_XZ, + preset=PRESET_DEFAULT, + encoding="utf-8", ) as lzma_file, open(path, "r", encoding="utf-8") as original_file, ): lzma_file.write(original_file.read()) path.unlink() - path = new_path + path = compressed_path # Rename with new number suffix new_number = self.get_path_number(path) + 1