gliphy / rpms / mcomix3

Forked from rpms/mcomix3 3 years ago
Clone

Blame 0001-Handle-encoding-exception-when-loading-bookmark-pick.patch

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