summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-03-18 10:09:00 +0100
committerStefan Behnel <stefan_ml@behnel.de>2017-03-18 10:09:00 +0100
commit6e1d219ffebebfabaf4408236f4d46c4990d782d (patch)
tree71c7a3b17fc5a8429ee23136a4b3f802cc24100c
parent82a354a2ad2a1ecafc729e619bd7875646250fcc (diff)
downloadpython-lxml-6e1d219ffebebfabaf4408236f4d46c4990d782d.tar.gz
improve type check and comment
-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()