@@ -1258,7 +1258,7 @@ def _iter_body(self, read, bufsize):
1258
1258
@staticmethod
1259
1259
def _iter_chunked (read , bufsize ):
1260
1260
err = HTTPError (400 , 'Error while parsing chunked transfer body.' )
1261
- rn , sem , bs = tob ( '\r \n ' ), tob ( ';' ), tob ( '' )
1261
+ rn , sem , bs = b '\r \n ', b ';', b''
1262
1262
while True :
1263
1263
header = read (1 )
1264
1264
while header [- 2 :] != rn :
@@ -1814,7 +1814,7 @@ def set_cookie(self, name, value, secret=None, digestmod=hashlib.sha256, **optio
1814
1814
encoded = base64 .b64encode (pickle .dumps ([name , value ], - 1 ))
1815
1815
sig = base64 .b64encode (hmac .new (tob (secret ), encoded ,
1816
1816
digestmod = digestmod ).digest ())
1817
- value = touni (tob ( '!' ) + sig + tob ( '?' ) + encoded )
1817
+ value = touni (b '!' + sig + b '?' + encoded )
1818
1818
elif not isinstance (value , basestring ):
1819
1819
raise TypeError ('Secret key required for non-string cookies.' )
1820
1820
@@ -2992,7 +2992,7 @@ def cookie_encode(data, key, digestmod=None):
2992
2992
digestmod = digestmod or hashlib .sha256
2993
2993
msg = base64 .b64encode (pickle .dumps (data , - 1 ))
2994
2994
sig = base64 .b64encode (hmac .new (tob (key ), msg , digestmod = digestmod ).digest ())
2995
- return tob ( '!' ) + sig + tob ( '?' ) + msg
2995
+ return b '!' + sig + b '?' + msg
2996
2996
2997
2997
2998
2998
def cookie_decode (data , key , digestmod = None ):
@@ -3001,7 +3001,7 @@ def cookie_decode(data, key, digestmod=None):
3001
3001
"Do not use this API directly." )
3002
3002
data = tob (data )
3003
3003
if cookie_is_encoded (data ):
3004
- sig , msg = data .split (tob ( '?' ) , 1 )
3004
+ sig , msg = data .split (b '?' , 1 )
3005
3005
digestmod = digestmod or hashlib .sha256
3006
3006
hashed = hmac .new (tob (key ), msg , digestmod = digestmod ).digest ()
3007
3007
if _lscmp (sig [1 :], base64 .b64encode (hashed )):
@@ -3013,7 +3013,7 @@ def cookie_is_encoded(data):
3013
3013
""" Return True if the argument looks like a encoded cookie."""
3014
3014
depr (0 , 13 , "cookie_is_encoded() will be removed soon." ,
3015
3015
"Do not use this API directly." )
3016
- return bool (data .startswith (tob ( '!' )) and tob ( '?' ) in data )
3016
+ return bool (data .startswith (b '!' ) and b '?' in data )
3017
3017
3018
3018
3019
3019
def html_escape (string ):
0 commit comments