File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 55syntax that can only be solved by conditionally importing different functions.
66"""
77import sys
8+ from lxml .etree import tostring
89
910if sys .version_info [0 ] == 2 :
1011 bytes_ = str
1112 str_ = unicode
13+ def tostring_ (s ):
14+ return tostring (s , encoding = 'utf-8' ).decode ('utf-8' )
1215
1316elif sys .version_info [0 ] == 3 :
1417 bytes_ = bytes
1518 str_ = str
19+ def tostring_ (s ):
20+ return tostring (s , encoding = 'utf-8' )
Original file line number Diff line number Diff line change 44import re
55import sys
66
7- from lxml .etree import tostring
87from lxml .etree import tounicode
98from lxml .html import document_fromstring
109from lxml .html import fragment_fromstring
1514from .htmls import get_body
1615from .htmls import get_title
1716from .htmls import shorten_title
18- from .compat import str_ , bytes_
17+ from .compat import str_ , bytes_ , tostring_
1918from .debug import describe , text_content
2019
2120
@@ -464,7 +463,7 @@ def transform_misused_divs_into_paragraphs(self):
464463 # This results in incorrect results in case there is an <img>
465464 # buried within an <a> for example
466465 if not REGEXES ["divToPElementsRe" ].search (
467- str_ (b"" .join (map (lambda it : tostring ( it , encoding = "utf-8" ) , list (elem ))))
466+ str_ (b"" .join (map (tostring_ , list (elem ))))
468467 ):
469468 # log.debug("Altering %s to p" % (describe(elem)))
470469 elem .tag = "p"
You can’t perform that action at this time.
0 commit comments