From 42db2659bf09478e063cce3444d1cfa392f9b7aa Mon Sep 17 00:00:00 2001
From: mcomix3 Fedora maintainer <mcomix3-owner@fedoraproject.org>
Date: Mon, 4 Nov 2019 14:07:16 +0900
Subject: [PATCH] Handle encoding exception when loading bookmark pickle from
mcomix
When loading bookmark pickle from mcomix, some exception may happen:
File "mcomix/mcomix/bookmark_backend.py", line 148, in load_bookmarks
packs = pickle.load(fd)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 1: ordinal not in range(128)
This patch avoids this.
---
mcomix/mcomix/bookmark_backend.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mcomix/mcomix/bookmark_backend.py b/mcomix/mcomix/bookmark_backend.py
index 0492600..d1080be 100644
--- a/mcomix/mcomix/bookmark_backend.py
+++ b/mcomix/mcomix/bookmark_backend.py
@@ -142,7 +142,10 @@ class __BookmarksStore(object):
mtime = os.stat(path).st_mtime
with open(path, 'rb') as fd:
version = pickle.load(fd)
- packs = pickle.load(fd)
+ try:
+ packs = pickle.load(fd)
+ except UnicodeDecodeError:
+ packs = pickle.load(fd, encoding='latin1')
for pack in packs:
# Handle old bookmarks without date_added attribute
--
2.23.0