Skip to content

Commit ed6340e

Browse files
jdufresnecarltongibson
authored andcommitted
Remove unnecessary use of compat shim six.binary_type (#6189)
The type bytes is available on all supported Pythons. On Python 2.7, it is an alias for str, same as six.binary_type. Makes the code more forward compatible with Python 3.
1 parent fc6cbb5 commit ed6340e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

rest_framework/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def unicode_to_repr(value):
9696

9797
def unicode_http_header(value):
9898
# Coerce HTTP header value to unicode.
99-
if isinstance(value, six.binary_type):
99+
if isinstance(value, bytes):
100100
return value.decode('iso-8859-1')
101101
return value
102102

rest_framework/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ def __new__(self, value):
17801780
def to_internal_value(self, data):
17811781
try:
17821782
if self.binary or getattr(data, 'is_json_string', False):
1783-
if isinstance(data, six.binary_type):
1783+
if isinstance(data, bytes):
17841784
data = data.decode('utf-8')
17851785
return json.loads(data)
17861786
else:

rest_framework/utils/encoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def default(self, obj):
4747
return six.text_type(obj)
4848
elif isinstance(obj, QuerySet):
4949
return tuple(obj)
50-
elif isinstance(obj, six.binary_type):
50+
elif isinstance(obj, bytes):
5151
# Best-effort for binary blobs. See #4187.
5252
return obj.decode('utf-8')
5353
elif hasattr(obj, 'tolist'):

0 commit comments

Comments
 (0)