diff --git a/lib/tools/common/patching_utils.py b/lib/tools/common/patching_utils.py index c102d2f6d1..074732364e 100644 --- a/lib/tools/common/patching_utils.py +++ b/lib/tools/common/patching_utils.py @@ -173,7 +173,13 @@ class PatchFileInDir: patches: list[PatchInPatchFile] = [] msg: mailbox.mboxMessage for msg in mbox: - patch: str = msg.get_payload() + patch: str + try: + patch = msg.get_payload(decode=True).decode("utf-8") + except UnicodeDecodeError as e: + log.error(f"Error decoding UTF-8 mbox payload in file {self.full_file_path()}(:{counter}): {e}") + patch = msg.get_payload() # this will mangle valid utf-8 + # split the patch itself and the description from the payload desc, patch_contents = self.split_description_and_patch(patch) if len(patch_contents) == 0: