summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2014-03-16 16:14:07 +0100
committerStefan Behnel <stefan_ml@behnel.de>2014-03-16 16:14:07 +0100
commit8347bd46100d1da3c068b608cbdf2d7469012223 (patch)
treef6f5b2cf23ee446fb607b884a260c2b2d0af402f /src
parentf69176ec9776e7f4becb238796e3ad1c123f9a93 (diff)
downloadpython-lxml-8347bd46100d1da3c068b608cbdf2d7469012223.tar.gz
fix HTML wrapping for bytes strings in Py3
--HG-- extra : transplant_source : %FA%A2p%CD%F9b%DD%AC%01%5E%CAt1%14%9C%97%C12b%5E
Diffstat (limited to 'src')
-rw-r--r--src/lxml/html/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lxml/html/__init__.py b/src/lxml/html/__init__.py
index 382d3272..fe28c3bb 100644
--- a/src/lxml/html/__init__.py
+++ b/src/lxml/html/__init__.py
@@ -620,7 +620,9 @@ def fragments_fromstring(html, no_leading_text=False, base_url=None,
# FIXME: check what happens when you give html with a body, head, etc.
if isinstance(html, bytes):
if not _looks_like_full_html_bytes(html):
- html = '<html><body>%s</body></html>'.encode('ascii') % html
+ # can't use %-formatting in early Py3 versions
+ html = ('<html><body>'.encode('ascii') + html +
+ '</body></html>'.encode('ascii'))
else:
if not _looks_like_full_html_unicode(html):
html = '<html><body>%s</body></html>' % html