1
1
from __future__ import absolute_import , division , unicode_literals
2
2
3
+ from six import text_type
4
+
3
5
from . import _base
4
6
from ..constants import cdataElements , rcdataElements , voidElements
5
7
@@ -21,7 +23,7 @@ def __iter__(self):
21
23
name = token ["name" ]
22
24
if contentModelFlag != "PCDATA" :
23
25
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 ):
25
27
raise LintError ("Tag name is not a string: %(tag)r" % {"tag" : name })
26
28
if not name :
27
29
raise LintError ("Empty tag name" )
@@ -32,11 +34,11 @@ def __iter__(self):
32
34
if type == "StartTag" :
33
35
open_elements .append (name )
34
36
for name , value in token ["data" ]:
35
- if not isinstance (name , str ):
37
+ if not isinstance (name , text_type ):
36
38
raise LintError ("Attribute name is not a string: %(name)r" % {"name" : name })
37
39
if not name :
38
40
raise LintError ("Empty attribute name" )
39
- if not isinstance (value , str ):
41
+ if not isinstance (value , text_type ):
40
42
raise LintError ("Attribute value is not a string: %(value)r" % {"value" : value })
41
43
if name in cdataElements :
42
44
contentModelFlag = "CDATA"
@@ -47,7 +49,7 @@ def __iter__(self):
47
49
48
50
elif type == "EndTag" :
49
51
name = token ["name" ]
50
- if not isinstance (name , str ):
52
+ if not isinstance (name , text_type ):
51
53
raise LintError ("Tag name is not a string: %(tag)r" % {"tag" : name })
52
54
if not name :
53
55
raise LintError ("Empty tag name" )
@@ -64,7 +66,7 @@ def __iter__(self):
64
66
65
67
elif type in ("Characters" , "SpaceCharacters" ):
66
68
data = token ["data" ]
67
- if not isinstance (data , str ):
69
+ if not isinstance (data , text_type ):
68
70
raise LintError ("Attribute name is not a string: %(name)r" % {"name" : data })
69
71
if not data :
70
72
raise LintError ("%(type)s token with empty data" % {"type" : type })
@@ -77,7 +79,7 @@ def __iter__(self):
77
79
name = token ["name" ]
78
80
if contentModelFlag != "PCDATA" :
79
81
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 ):
81
83
raise LintError ("Tag name is not a string: %(tag)r" % {"tag" : name })
82
84
# XXX: what to do with token["data"] ?
83
85
0 commit comments