Fix #1900337 [Error when replacing db.prefs settings](https://bugs.launchpad.net/calibre/+bug/1900337)

This commit is contained in:
Kovid Goyal 2020-10-18 22:03:50 +05:30
parent f9dfae2bc9
commit 7b6ec6515a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -153,6 +153,13 @@ class ThreadSafePrefs(MutableMapping):
prefs = self.db().backend.prefs prefs = self.db().backend.prefs
return prefs.to_raw(val) 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): class LibraryDatabase(object):