From 457eea7407b19cb40d0f5bdfaeb772d0ba234a6e Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 9 May 2019 10:37:43 -0400 Subject: [PATCH] py3: use correct __next__ method I'm not sure why this is storing a seemingly unused method-wrapper object, but it needs to use the correctly named one on python2/python3. --- src/calibre/srv/render_book.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index 407c457889..c269f6d015 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -31,7 +31,7 @@ from calibre.ebooks.oeb.polish.utils import extract, guess_type from calibre.utils.logging import default_log from calibre.utils.short_uuid import uuid4 from polyglot.binary import as_base64_unicode as encode_component, from_base64_unicode as decode_component -from polyglot.builtins import iteritems, map, unicode_type +from polyglot.builtins import iteritems, map, is_py3, unicode_type from polyglot.urllib import quote, urlparse RENDER_VERSION = 1 @@ -501,7 +501,10 @@ def html_as_dict(root): if child.tag.partition('}')[-1] not in ('head', 'body'): root.remove(child) root.text = root.tail = None - nsmap = defaultdict(count().next) + if is_py3: + nsmap = defaultdict(count().__next__) + else: + nsmap = defaultdict(count().next) nsmap[XHTML_NS] tags = [serialize_elem(root, nsmap)] tree = [0]