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.
This commit is contained in:
Jon Dufresne 2018-09-17 01:39:59 -07:00 committed by Carlton Gibson
parent fc6cbb5b26
commit ed6340ee76
3 changed files with 3 additions and 3 deletions

View File

@ -96,7 +96,7 @@ def unicode_to_repr(value):
def unicode_http_header(value):
# Coerce HTTP header value to unicode.
if isinstance(value, six.binary_type):
if isinstance(value, bytes):
return value.decode('iso-8859-1')
return value

View File

@ -1780,7 +1780,7 @@ class JSONField(Field):
def to_internal_value(self, data):
try:
if self.binary or getattr(data, 'is_json_string', False):
if isinstance(data, six.binary_type):
if isinstance(data, bytes):
data = data.decode('utf-8')
return json.loads(data)
else:

View File

@ -47,7 +47,7 @@ class JSONEncoder(json.JSONEncoder):
return six.text_type(obj)
elif isinstance(obj, QuerySet):
return tuple(obj)
elif isinstance(obj, six.binary_type):
elif isinstance(obj, bytes):
# Best-effort for binary blobs. See #4187.
return obj.decode('utf-8')
elif hasattr(obj, 'tolist'):