1
1
2
- from six import text_type
3
-
4
2
from . import base
5
3
from ..constants import namespaces , voidElements
6
4
@@ -32,9 +30,9 @@ def __iter__(self):
32
30
if type in ("StartTag" , "EmptyTag" ):
33
31
namespace = token ["namespace" ]
34
32
name = token ["name" ]
35
- assert namespace is None or isinstance (namespace , text_type )
33
+ assert namespace is None or isinstance (namespace , str )
36
34
assert namespace != ""
37
- assert isinstance (name , text_type )
35
+ assert isinstance (name , str )
38
36
assert name != ""
39
37
assert isinstance (token ["data" ], dict )
40
38
if (not namespace or namespace == namespaces ["html" ]) and name in voidElements :
@@ -44,18 +42,18 @@ def __iter__(self):
44
42
if type == "StartTag" and self .require_matching_tags :
45
43
open_elements .append ((namespace , name ))
46
44
for (namespace , name ), value in token ["data" ].items ():
47
- assert namespace is None or isinstance (namespace , text_type )
45
+ assert namespace is None or isinstance (namespace , str )
48
46
assert namespace != ""
49
- assert isinstance (name , text_type )
47
+ assert isinstance (name , str )
50
48
assert name != ""
51
- assert isinstance (value , text_type )
49
+ assert isinstance (value , str )
52
50
53
51
elif type == "EndTag" :
54
52
namespace = token ["namespace" ]
55
53
name = token ["name" ]
56
- assert namespace is None or isinstance (namespace , text_type )
54
+ assert namespace is None or isinstance (namespace , str )
57
55
assert namespace != ""
58
- assert isinstance (name , text_type )
56
+ assert isinstance (name , str )
59
57
assert name != ""
60
58
if (not namespace or namespace == namespaces ["html" ]) and name in voidElements :
61
59
assert False , "Void element reported as EndTag token: %(tag)s" % {"tag" : name }
@@ -65,26 +63,26 @@ def __iter__(self):
65
63
66
64
elif type == "Comment" :
67
65
data = token ["data" ]
68
- assert isinstance (data , text_type )
66
+ assert isinstance (data , str )
69
67
70
68
elif type in ("Characters" , "SpaceCharacters" ):
71
69
data = token ["data" ]
72
- assert isinstance (data , text_type )
70
+ assert isinstance (data , str )
73
71
assert data != ""
74
72
if type == "SpaceCharacters" :
75
73
assert data .strip (spaceCharacters ) == ""
76
74
77
75
elif type == "Doctype" :
78
76
name = token ["name" ]
79
- assert name is None or isinstance (name , text_type )
80
- assert token ["publicId" ] is None or isinstance (name , text_type )
81
- assert token ["systemId" ] is None or isinstance (name , text_type )
77
+ assert name is None or isinstance (name , str )
78
+ assert token ["publicId" ] is None or isinstance (name , str )
79
+ assert token ["systemId" ] is None or isinstance (name , str )
82
80
83
81
elif type == "Entity" :
84
- assert isinstance (token ["name" ], text_type )
82
+ assert isinstance (token ["name" ], str )
85
83
86
84
elif type == "SerializerError" :
87
- assert isinstance (token ["data" ], text_type )
85
+ assert isinstance (token ["data" ], str )
88
86
89
87
else :
90
88
assert False , "Unknown token type: %(type)s" % {"type" : type }
0 commit comments