Skip to content

Commit 40c3ba6

Browse files
committed
Fix lint to expect text_type everywhere
1 parent af0199c commit 40c3ba6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

html5lib/filters/lint.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3+
from six import text_type
4+
35
from . import _base
46
from ..constants import cdataElements, rcdataElements, voidElements
57

@@ -21,7 +23,7 @@ def __iter__(self):
2123
name = token["name"]
2224
if contentModelFlag != "PCDATA":
2325
raise LintError("StartTag not in PCDATA content model flag: %(tag)s" % {"tag": name})
24-
if not isinstance(name, str):
26+
if not isinstance(name, text_type):
2527
raise LintError("Tag name is not a string: %(tag)r" % {"tag": name})
2628
if not name:
2729
raise LintError("Empty tag name")
@@ -32,11 +34,11 @@ def __iter__(self):
3234
if type == "StartTag":
3335
open_elements.append(name)
3436
for name, value in token["data"]:
35-
if not isinstance(name, str):
37+
if not isinstance(name, text_type):
3638
raise LintError("Attribute name is not a string: %(name)r" % {"name": name})
3739
if not name:
3840
raise LintError("Empty attribute name")
39-
if not isinstance(value, str):
41+
if not isinstance(value, text_type):
4042
raise LintError("Attribute value is not a string: %(value)r" % {"value": value})
4143
if name in cdataElements:
4244
contentModelFlag = "CDATA"
@@ -47,7 +49,7 @@ def __iter__(self):
4749

4850
elif type == "EndTag":
4951
name = token["name"]
50-
if not isinstance(name, str):
52+
if not isinstance(name, text_type):
5153
raise LintError("Tag name is not a string: %(tag)r" % {"tag": name})
5254
if not name:
5355
raise LintError("Empty tag name")
@@ -64,7 +66,7 @@ def __iter__(self):
6466

6567
elif type in ("Characters", "SpaceCharacters"):
6668
data = token["data"]
67-
if not isinstance(data, str):
69+
if not isinstance(data, text_type):
6870
raise LintError("Attribute name is not a string: %(name)r" % {"name": data})
6971
if not data:
7072
raise LintError("%(type)s token with empty data" % {"type": type})
@@ -77,7 +79,7 @@ def __iter__(self):
7779
name = token["name"]
7880
if contentModelFlag != "PCDATA":
7981
raise LintError("Doctype not in PCDATA content model flag: %(name)s" % {"name": name})
80-
if not isinstance(name, str):
82+
if not isinstance(name, text_type):
8183
raise LintError("Tag name is not a string: %(tag)r" % {"tag": name})
8284
# XXX: what to do with token["data"] ?
8385

0 commit comments

Comments
 (0)