1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-23 22:51:30 +02:00

Removing couple of "buildins" polyglot types

This commit is contained in:
2020-04-20 20:22:50 +02:00
parent eac0b98d6f
commit c867f0321b
36 changed files with 85 additions and 109 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ from ebook_converter import xml_replace_entities, force_unicode
from ebook_converter.utils.xml_parse import safe_xml_fromstring
from ebook_converter.constants import filesystem_encoding
from ebook_converter.ebooks.chardet import xml_to_unicode, strip_encoding_declarations
from ebook_converter.polyglot.builtins import iteritems, itervalues, string_or_bytes
from ebook_converter.polyglot.builtins import iteritems, itervalues
__license__ = 'GPL v3'
@@ -96,7 +96,7 @@ def html5_parse(data, max_nesting_depth=100):
# Check that the asinine HTML 5 algorithm did not result in a tree with
# insane nesting depths
for x in data.iterdescendants():
if isinstance(x.tag, string_or_bytes) and not len(x): # Leaf node
if isinstance(x.tag, (str, bytes)) and not len(x): # Leaf node
depth = node_depth(x)
if depth > max_nesting_depth:
raise ValueError('HTML 5 parsing resulted in a tree with nesting'
@@ -294,7 +294,7 @@ def parse_html(data, log=None, decoder=None, preprocessor=None,
nroot = etree.Element(XHTML('html'),
nsmap={None: XHTML_NS}, attrib=attrib)
for elem in data.iterdescendants():
if isinstance(elem.tag, string_or_bytes) and \
if isinstance(elem.tag, (str, bytes)) and \
namespace(elem.tag) == ns:
elem.tag = XHTML(barename(elem.tag))
for elem in data: