From 6529a07ff5b901e10d2ab0011cd5a9e7cb4ee5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Valdemar=20M=C3=B8rch?= Date: Thu, 27 Feb 2025 12:57:03 +0100 Subject: [PATCH] Handle UTF-8 decoding errors gracefully create-example.sh now touches a new file with a non-UTF-8 filename that would cause it to fail without the patch to btrfs-snapshots-diff.py but I cannot fix the tests because of #23. --- btrfs-snapshots-diff.py | 2 +- create-example.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/btrfs-snapshots-diff.py b/btrfs-snapshots-diff.py index 8cd1ce4..93b81f1 100755 --- a/btrfs-snapshots-diff.py +++ b/btrfs-snapshots-diff.py @@ -106,7 +106,7 @@ def _tlv_get_string(self, attr_type, index): (ret,) = unpack( f'<{l_attr}s', self.stream[index + self.l_tlv : index + self.l_tlv + l_attr] ) - return index + self.l_tlv + l_attr, ret.decode('utf8') + return index + self.l_tlv + l_attr, ret.decode('utf8', errors='replace') def _tlv_get_u64(self, attr_type, index): attr, l_attr = unpack('