From 1a2bbfce5c7a370cff72755f49a4c1aed385ae9b Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sun, 31 Jul 2016 23:13:04 +0300 Subject: [PATCH] Remove deprecated decode param from resp.read(decode=True) --- CHANGES.txt | 2 ++ aiohttp/client_reqrep.py | 12 ++---------- tests/test_client_response.py | 11 ----------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index dd249acc4e8..1958ab69837 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -49,6 +49,8 @@ CHANGES - Rename Message -> WSMessage +- Remove deprecated decode param from resp.read(decode=True) + 0.22.3 (07-26-2016) ------------------- diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 2da9ba32123..3c5a12c9099 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -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: @@ -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() diff --git a/tests/test_client_response.py b/tests/test_client_response.py index ff8156abd92..a03a7134eee 100644 --- a/tests/test_client_response.py +++ b/tests/test_client_response.py @@ -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)