From d28d68cb1696d3e8f77fbce759d6c85fd438fa12 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 7 Jan 2021 13:05:43 +0100 Subject: [PATCH] backup: Ensure entries in the tx are bytes We could end up in some cases with string-encoded statements. --- backup/backup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backup/backup.py b/backup/backup.py index c33ce639..ce1b171b 100755 --- a/backup/backup.py +++ b/backup/backup.py @@ -192,7 +192,8 @@ class FileBackend(Backend): def add_change(self, entry: Change) -> bool: typ = b'\x01' if entry.snapshot is None else b'\x02' if typ == b'\x01': - payload = b'\x00'.join([t.encode('UTF-8') for t in entry.transaction]) + stmts = [t.encode('UTF-8') if isinstance(t, str) else t for t in entry.transaction] + payload = b'\x00'.join(stmts) elif typ == b'\x02': payload = entry.snapshot