Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Fixed another regression from 2892cb0.

  • Loading branch information...
commit 5f2d9cdbb1b1a8c91dcdd55e672801536711b5ef 1 parent 2892cb0
@aaugustin aaugustin authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 django/http/__init__.py
View
15 django/http/__init__.py
@@ -673,11 +673,11 @@ def _get_content(self):
if self.has_header('Content-Encoding'):
def make_bytes(value):
if isinstance(value, int):
- return six.text_type(value).encode()
- elif isinstance(value, six.text_type):
- return value.encode('ascii')
- else:
- return bytes(value)
+ value = six.text_type(value)
+ if isinstance(value, six.text_type):
+ value = value.encode('ascii')
+ # force conversion to bytes in case chunk is a subclass
+ return bytes(value)
return b''.join(make_bytes(e) for e in self._container)
return b''.join(smart_bytes(e, self._charset) for e in self._container)
@@ -698,9 +698,10 @@ def __iter__(self):
def __next__(self):
chunk = next(self._iterator)
if isinstance(chunk, int):
- return six.text_type(chunk).encode()
+ chunk = six.text_type(chunk)
if isinstance(chunk, six.text_type):
- return chunk.encode(self._charset)
+ chunk = chunk.encode(self._charset)
+ # force conversion to bytes in case chunk is a subclass
return bytes(chunk)
next = __next__ # Python 2 compatibility

0 comments on commit 5f2d9cd

Please sign in to comment.
Something went wrong with that request. Please try again.