summaryrefslogtreecommitdiff
path: root/src/lxml/html
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-03-18 10:12:25 +0100
committerStefan Behnel <stefan_ml@behnel.de>2017-03-18 10:12:25 +0100
commita79307c5173963beb7bd03e54339e6ff7f11fb81 (patch)
tree6b5f73668ed161348c0ef85c6ba3ac418fa940a4 /src/lxml/html
parent91e1d273549e29510a8f431ba561381514600575 (diff)
parent2d35d07293b9115120e84193f51035aab094f2e8 (diff)
downloadpython-lxml-a79307c5173963beb7bd03e54339e6ff7f11fb81.tar.gz
merge lxml-3.7 branch into master
Diffstat (limited to 'src/lxml/html')
-rw-r--r--src/lxml/html/html5parser.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lxml/html/html5parser.py b/src/lxml/html/html5parser.py
index ba9d41b3..ed70b340 100644
--- a/src/lxml/html/html5parser.py
+++ b/src/lxml/html/html5parser.py
@@ -148,10 +148,10 @@ def fromstring(html, guess_charset=True, parser=None):
# document starts with doctype or <html>, full document!
start = html[:50]
- if hasattr(start, 'decode'):
- # In python3, we may have been presented with a bytes object.
- # Decode in ascii, that also covers latin-1 and utf-8 for the
- # characters we need
+ if isinstance(start, bytes):
+ # Allow text comparison in python3.
+ # Decode as ascii, that also covers latin-1 and utf-8 for the
+ # characters we need.
start = start.decode('ascii', 'replace')
start = start.lstrip().lower()