From f915f11a0c30fbe28a6083110b64077aedecde27 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 26 May 2019 21:29:41 -0400 Subject: [PATCH] py3: fix dict.keys() usage micro-optimize: if r.keys() is empty, r is empty first. --- src/calibre/ebooks/chm/metadata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/chm/metadata.py b/src/calibre/ebooks/chm/metadata.py index 8384263b4b..a822428fde 100644 --- a/src/calibre/ebooks/chm/metadata.py +++ b/src/calibre/ebooks/chm/metadata.py @@ -14,6 +14,7 @@ from calibre.ebooks.metadata import string_to_authors, MetaInformation from calibre.utils.logging import default_log from calibre.ptempfile import TemporaryFile from calibre import force_unicode +from polyglot.builtins import iterkeys def _clean(s): @@ -110,9 +111,8 @@ def _get_cover(soup, rdr): except: # Probably invalid width, height aattributes, ignore continue - l = r.keys() - l.sort() - if l: + if r: + l = sorted(iterkeys(r)) ans = r[l[0]] # this link comes from the internal html, which is in a subdir if ans is not None: