3
3
from gettext import gettext
4
4
_ = gettext
5
5
6
+ from six import text_type
7
+
6
8
from . import _base
7
9
from ..constants import cdataElements , rcdataElements , voidElements
8
10
@@ -24,7 +26,7 @@ def __iter__(self):
24
26
name = token ["name" ]
25
27
if contentModelFlag != "PCDATA" :
26
28
raise LintError (_ ("StartTag not in PCDATA content model flag: %(tag)s" ) % {"tag" : name })
27
- if not isinstance (name , str ):
29
+ if not isinstance (name , text_type ):
28
30
raise LintError (_ ("Tag name is not a string: %(tag)r" ) % {"tag" : name })
29
31
if not name :
30
32
raise LintError (_ ("Empty tag name" ))
@@ -34,12 +36,14 @@ def __iter__(self):
34
36
raise LintError (_ ("Non-void element reported as EmptyTag token: %(tag)s" ) % {"tag" : token ["name" ]})
35
37
if type == "StartTag" :
36
38
open_elements .append (name )
37
- for name , value in token ["data" ]:
38
- if not isinstance (name , str ):
39
+ for (ns , name ), value in token ["data" ].items ():
40
+ if ns is not None and not isinstance (ns , text_type ):
41
+ raise LintError (_ ("Attribute namespace is not None or a string: %(name)r" ) % {"name" : name })
42
+ if not isinstance (name , text_type ):
39
43
raise LintError (_ ("Attribute name is not a string: %(name)r" ) % {"name" : name })
40
44
if not name :
41
45
raise LintError (_ ("Empty attribute name" ))
42
- if not isinstance (value , str ):
46
+ if not isinstance (value , text_type ):
43
47
raise LintError (_ ("Attribute value is not a string: %(value)r" ) % {"value" : value })
44
48
if name in cdataElements :
45
49
contentModelFlag = "CDATA"
@@ -50,7 +54,7 @@ def __iter__(self):
50
54
51
55
elif type == "EndTag" :
52
56
name = token ["name" ]
53
- if not isinstance (name , str ):
57
+ if not isinstance (name , text_type ):
54
58
raise LintError (_ ("Tag name is not a string: %(tag)r" ) % {"tag" : name })
55
59
if not name :
56
60
raise LintError (_ ("Empty tag name" ))
@@ -67,7 +71,7 @@ def __iter__(self):
67
71
68
72
elif type in ("Characters" , "SpaceCharacters" ):
69
73
data = token ["data" ]
70
- if not isinstance (data , str ):
74
+ if not isinstance (data , text_type ):
71
75
raise LintError (_ ("Attribute name is not a string: %(name)r" ) % {"name" : data })
72
76
if not data :
73
77
raise LintError (_ ("%(type)s token with empty data" ) % {"type" : type })
@@ -80,7 +84,7 @@ def __iter__(self):
80
84
name = token ["name" ]
81
85
if contentModelFlag != "PCDATA" :
82
86
raise LintError (_ ("Doctype not in PCDATA content model flag: %(name)s" ) % {"name" : name })
83
- if not isinstance (name , str ):
87
+ if not isinstance (name , text_type ):
84
88
raise LintError (_ ("Tag name is not a string: %(tag)r" ) % {"tag" : name })
85
89
# XXX: what to do with token["data"] ?
86
90
0 commit comments