Skip to content

Commit

Permalink
Remove deprecated decode param from resp.read(decode=True)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 31, 2016
1 parent 35005c4 commit 1a2bbfc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ CHANGES

- Rename Message -> WSMessage

- Remove deprecated decode param from resp.read(decode=True)

0.22.3 (07-26-2016)
-------------------

Expand Down
12 changes: 2 additions & 10 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def wait_for_close(self):
yield from self.release()

@asyncio.coroutine
def read(self, decode=False):
def read(self):
"""Read response payload."""
if self._content is None:
try:
Expand All @@ -731,15 +731,7 @@ def read(self, decode=False):
else:
yield from self.release()

data = self._content

if decode:
warnings.warn(
'.read(True) is deprecated. use .json() instead',
DeprecationWarning)
return (yield from self.json())

return data
return self._content

def _get_encoding(self):
ctype = self.headers.get(hdrs.CONTENT_TYPE, '').lower()
Expand Down
11 changes: 0 additions & 11 deletions tests/test_client_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,6 @@ def test_release(self):
self.loop.run_until_complete(self.response.release())
self.assertIsNone(self.response._connection)

def test_read_decode_deprecated(self):
self.response._content = b'data'
self.response.json = mock.Mock()
self.response.json.return_value = helpers.create_future(self.loop)
self.response.json.return_value.set_result('json')

with self.assertWarns(DeprecationWarning):
res = self.loop.run_until_complete(self.response.read(decode=True))
self.assertEqual(res, 'json')
self.assertTrue(self.response.json.called)

def test_text(self):
def side_effect(*args, **kwargs):
fut = helpers.create_future(self.loop)
Expand Down

0 comments on commit 1a2bbfc

Please sign in to comment.