From 7b6ec6515a199259156d95766aa73496be6eb9fb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 18 Oct 2020 22:03:50 +0530 Subject: [PATCH] Fix #1900337 [Error when replacing db.prefs settings](https://bugs.launchpad.net/calibre/+bug/1900337) --- src/calibre/db/legacy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/db/legacy.py b/src/calibre/db/legacy.py index 7bb0d6c0dc..cb2b4901dd 100644 --- a/src/calibre/db/legacy.py +++ b/src/calibre/db/legacy.py @@ -153,6 +153,13 @@ class ThreadSafePrefs(MutableMapping): prefs = self.db().backend.prefs return prefs.to_raw(val) + def raw_to_object(self, raw): + if isinstance(raw, bytes): + raw = raw.decode(preferred_encoding) + import json + from calibre.utils.config import from_json + return json.loads(raw, object_hook=from_json) + class LibraryDatabase(object):