[py3] Fixed another regression from 2892cb0ec4.

This commit is contained in:
Aymeric Augustin 2012-08-19 18:23:28 +02:00
parent 2892cb0ec4
commit 5f2d9cdbb1
1 changed files with 8 additions and 7 deletions

View File

@ -673,10 +673,10 @@ class HttpResponse(object):
if self.has_header('Content-Encoding'): if self.has_header('Content-Encoding'):
def make_bytes(value): def make_bytes(value):
if isinstance(value, int): if isinstance(value, int):
return six.text_type(value).encode() value = six.text_type(value)
elif isinstance(value, six.text_type): if isinstance(value, six.text_type):
return value.encode('ascii') value = value.encode('ascii')
else: # force conversion to bytes in case chunk is a subclass
return bytes(value) return bytes(value)
return b''.join(make_bytes(e) for e in self._container) return b''.join(make_bytes(e) for e in self._container)
return b''.join(smart_bytes(e, self._charset) for e in self._container) return b''.join(smart_bytes(e, self._charset) for e in self._container)
@ -698,9 +698,10 @@ class HttpResponse(object):
def __next__(self): def __next__(self):
chunk = next(self._iterator) chunk = next(self._iterator)
if isinstance(chunk, int): if isinstance(chunk, int):
return six.text_type(chunk).encode() chunk = six.text_type(chunk)
if isinstance(chunk, six.text_type): 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) return bytes(chunk)
next = __next__ # Python 2 compatibility next = __next__ # Python 2 compatibility