##// END OF EJS Templates
add py3compat.buffer_to_bytes_py2...
Min RK -
Show More
@@ -30,6 +30,12 b' def cast_bytes(s, encoding=None):'
30 return encode(s, encoding)
30 return encode(s, encoding)
31 return s
31 return s
32
32
33 def buffer_to_bytes(buf):
34 """Cast a buffer object to bytes"""
35 if not isinstance(buf, bytes):
36 buf = bytes(buf)
37 return buf
38
33 def _modify_str_or_docstring(str_change_func):
39 def _modify_str_or_docstring(str_change_func):
34 @functools.wraps(str_change_func)
40 @functools.wraps(str_change_func)
35 def wrapper(func_or_str):
41 def wrapper(func_or_str):
@@ -86,6 +92,7 b' if sys.version_info[0] >= 3:'
86 bytes_to_str = decode
92 bytes_to_str = decode
87 cast_bytes_py2 = no_code
93 cast_bytes_py2 = no_code
88 cast_unicode_py2 = no_code
94 cast_unicode_py2 = no_code
95 buffer_to_bytes_py2 = no_code
89
96
90 string_types = (str,)
97 string_types = (str,)
91 unicode_type = str
98 unicode_type = str
@@ -151,6 +158,7 b' else:'
151 bytes_to_str = no_code
158 bytes_to_str = no_code
152 cast_bytes_py2 = cast_bytes
159 cast_bytes_py2 = cast_bytes
153 cast_unicode_py2 = cast_unicode
160 cast_unicode_py2 = cast_unicode
161 buffer_to_bytes_py2 = buffer_to_bytes
154
162
155 string_types = (str, unicode)
163 string_types = (str, unicode)
156 unicode_type = unicode
164 unicode_type = unicode
General Comments 0
You need to be logged in to leave comments. Login now