From a2c558d864ac4a97391586dfc17f463cca07ba15 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 16 Dec 2019 16:33:38 -0500 Subject: [PATCH] python3: fix incorrect use of merging two dictionaries In python2, this was inefficient, because it allocated *three* lists of tuples, before finally generating a dict based on them. In python3, it fails because you cannot combine the dict_items() type. Moreover, retval was always a function-local dictionary used purely for returning the value, so dict1.update(dict2) will always yield the correct result, and we don't even need to create a copy to avoid mutating the original dictionary. --- calibre-plugin/dialogs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/calibre-plugin/dialogs.py b/calibre-plugin/dialogs.py index 781877b4..076a1866 100644 --- a/calibre-plugin/dialogs.py +++ b/calibre-plugin/dialogs.py @@ -491,7 +491,8 @@ class AddNewDialog(SizePersistedDialog): retval['updatemeta']=True retval['collision']=ADDNEW - return dict(retval.items() + self.extraoptions.items() ) + retval.update(self.extraoptions) + return retval def get_urlstext(self): return unicode(self.url.toPlainText())