Show More
@@ -30,6 +30,12 b' def cast_bytes(s, encoding=None):' | |||
|
30 | 30 | return encode(s, encoding) |
|
31 | 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 | 39 | def _modify_str_or_docstring(str_change_func): |
|
34 | 40 | @functools.wraps(str_change_func) |
|
35 | 41 | def wrapper(func_or_str): |
@@ -86,6 +92,7 b' if sys.version_info[0] >= 3:' | |||
|
86 | 92 | bytes_to_str = decode |
|
87 | 93 | cast_bytes_py2 = no_code |
|
88 | 94 | cast_unicode_py2 = no_code |
|
95 | buffer_to_bytes_py2 = no_code | |
|
89 | 96 | |
|
90 | 97 | string_types = (str,) |
|
91 | 98 | unicode_type = str |
@@ -151,6 +158,7 b' else:' | |||
|
151 | 158 | bytes_to_str = no_code |
|
152 | 159 | cast_bytes_py2 = cast_bytes |
|
153 | 160 | cast_unicode_py2 = cast_unicode |
|
161 | buffer_to_bytes_py2 = buffer_to_bytes | |
|
154 | 162 | |
|
155 | 163 | string_types = (str, unicode) |
|
156 | 164 | unicode_type = unicode |
General Comments 0
You need to be logged in to leave comments.
Login now