11from __future__import absolute_import ,division ,unicode_literals
22
3+ from six import text_type
4+
35from .import _base
46from ..constants import cdataElements ,rcdataElements ,voidElements
57
@@ -21,7 +23,7 @@ def __iter__(self):
2123name = token ["name" ]
2224if contentModelFlag != "PCDATA" :
2325raise 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 ):
2527raise LintError ("Tag name is not a string: %(tag)r" % {"tag" :name })
2628if not name :
2729raise LintError ("Empty tag name" )
@@ -32,11 +34,11 @@ def __iter__(self):
3234if type == "StartTag" :
3335open_elements .append (name )
3436for name ,value in token ["data" ]:
35- if not isinstance (name ,str ):
37+ if not isinstance (name ,text_type ):
3638raise LintError ("Attribute name is not a string: %(name)r" % {"name" :name })
3739if not name :
3840raise LintError ("Empty attribute name" )
39- if not isinstance (value ,str ):
41+ if not isinstance (value ,text_type ):
4042raise LintError ("Attribute value is not a string: %(value)r" % {"value" :value })
4143if name in cdataElements :
4244contentModelFlag = "CDATA"
@@ -47,7 +49,7 @@ def __iter__(self):
4749
4850elif type == "EndTag" :
4951name = token ["name" ]
50- if not isinstance (name ,str ):
52+ if not isinstance (name ,text_type ):
5153raise LintError ("Tag name is not a string: %(tag)r" % {"tag" :name })
5254if not name :
5355raise LintError ("Empty tag name" )
@@ -64,7 +66,7 @@ def __iter__(self):
6466
6567elif type in ("Characters" ,"SpaceCharacters" ):
6668data = token ["data" ]
67- if not isinstance (data ,str ):
69+ if not isinstance (data ,text_type ):
6870raise LintError ("Attribute name is not a string: %(name)r" % {"name" :data })
6971if not data :
7072raise LintError ("%(type)s token with empty data" % {"type" :type })
@@ -77,7 +79,7 @@ def __iter__(self):
7779name = token ["name" ]
7880if contentModelFlag != "PCDATA" :
7981raise 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 ):
8183raise LintError ("Tag name is not a string: %(tag)r" % {"tag" :name })
8284# XXX: what to do with token["data"] ?
8385