8
8
from sphinx import addnodes , util
9
9
from sphinx .locale import admonitionlabels
10
10
11
+ from . import pycompat
12
+
11
13
12
14
def _parents (node ):
13
15
while node .parent :
@@ -59,7 +61,7 @@ def __init__(self, builder, document):
59
61
self .param_separator = ','
60
62
61
63
def encode (self , text ):
62
- return unicode (text ).translate ({
64
+ return pycompat . to_text (text ).translate ({
63
65
ord ('&' ): u'&' ,
64
66
ord ('<' ): u'<' ,
65
67
ord ('"' ): u'"' ,
@@ -68,7 +70,7 @@ def encode(self, text):
68
70
})
69
71
70
72
def starttag (self , node , tagname , ** attributes ):
71
- tagname = unicode (tagname ).lower ()
73
+ tagname = pycompat . to_text (tagname ).lower ()
72
74
73
75
# extract generic attributes
74
76
attrs = {name .lower (): value for name , value in attributes .items ()}
@@ -103,7 +105,7 @@ def starttag(self, node, tagname, **attributes):
103
105
# only "space characters" SPACE, CHARACTER TABULATION, LINE FEED,
104
106
# FORM FEED and CARRIAGE RETURN should be collapsed, not al White_Space
105
107
def attval (self , value , whitespace = re .compile (u'[ \t \n \f \r ]' )):
106
- return self .encode (whitespace .sub (u' ' , unicode (value )))
108
+ return self .encode (whitespace .sub (u' ' , pycompat . to_text (value )))
107
109
108
110
def astext (self ):
109
111
return u'' .join (self .body )
0 commit comments