Skip to content

Commit

Permalink
Add a DeprecationWarning, while using old loader arg.
Browse files Browse the repository at this point in the history
  • Loading branch information
playpauseandstop committed Nov 27, 2015
1 parent e50da35 commit 78fa7c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aiohttp/web_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,13 @@ def text(self):
return bytes_body.decode(encoding)

@asyncio.coroutine
def json(self, *, loads=json.loads):
def json(self, *, loads=json.loads, loader=None):
"""Return BODY as JSON."""
if loader:
warnings.warn(
'Using `loader` is deprecated, use `loads` instead',
DeprecationWarning)
loads = loader
body = yield from self.text()
return loads(body)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_web_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def handler(request):
self.assertEqual(dct, data)
data2 = yield from request.json(loads=json.loads)
self.assertEqual(data, data2)
data3 = yield from request.json(loader=json.loads)
self.assertEqual(data, data3)
resp = web.Response()
resp.content_type = 'application/json'
resp.body = json.dumps(data).encode('utf8')
Expand Down

0 comments on commit 78fa7c3

Please sign in to comment.