From 06a665012bc1a8f0e2f2b5ba06f1d677c3adf18a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Sep 2020 06:43:00 +0530 Subject: [PATCH] Make ThreadSafePrefs an instance of MutableMapping So dict(prefs) works and th etest does not need to be changed --- src/calibre/db/legacy.py | 3 ++- src/calibre/db/tests/legacy.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/legacy.py b/src/calibre/db/legacy.py index ebfe6b7199..359d368ab6 100644 --- a/src/calibre/db/legacy.py +++ b/src/calibre/db/legacy.py @@ -7,6 +7,7 @@ __copyright__ = '2013, Kovid Goyal ' import os, traceback, weakref from polyglot.builtins import iteritems, zip +from collections.abc import MutableMapping from calibre import force_unicode, isbytestring from calibre.constants import preferred_encoding @@ -52,7 +53,7 @@ def set_global_state(db): set_saved_searches(db, 'saved_searches') -class ThreadSafePrefs: +class ThreadSafePrefs(MutableMapping): def __init__(self, db): self.db = weakref.ref(db) diff --git a/src/calibre/db/tests/legacy.py b/src/calibre/db/tests/legacy.py index bf71f715e0..af95b0ea76 100644 --- a/src/calibre/db/tests/legacy.py +++ b/src/calibre/db/tests/legacy.py @@ -189,7 +189,7 @@ class LegacyTest(BaseTest): db = self.init_old() newstag = ndb.new_api.get_item_id('tags', 'news') - self.assertEqual(dict(db.prefs), ndb.prefs.copy()) + self.assertEqual(dict(db.prefs), dict(ndb.prefs)) for meth, args in iteritems({ 'find_identical_books': [(Metadata('title one', ['author one']),), (Metadata('unknown'),), (Metadata('xxxx'),)],