Skip to content

Commit 4182a93

Browse files
authored
Bug fix (#13)
* mini fix * change asyncio.corutine to async/await
1 parent 6ea32b5 commit 4182a93

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

docs/release-notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Medium version numbers (0.x.0) may include API changes, in line with the [deprec
88

99
Major version numbers (x.0.0) are reserved for substantial project milestones.
1010

11+
### 0.3.7
12+
13+
**Date:** [15th August 2019]
14+
15+
* Change `@asyncio.coroutine` to `async/await`.
16+
1117
### 0.3.6
1218

1319
**Date:** [14th August 2019]

rest_framework/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
__/ |
99
|___/
1010
"""
11-
VERSION = (0, 3, 6)
11+
VERSION = (0, 3, 7)
1212

1313
__title__ = 'Python-Rest-Framework'
1414
__author__ = 'Deys Timofey'

rest_framework/views/aiohttp/mixins.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Mixins for views AioHttp.
33
44
"""
5-
import asyncio
65
try:
76
from json.decoder import JSONDecodeError
87
except (AttributeError, ImportError):
@@ -17,8 +16,7 @@ class GetValidJsonMixin(GetSerializerMixin):
1716
Mixin for method get_valid json.
1817
1918
"""
20-
@asyncio.coroutine
21-
def get_valid_json(self, parse_query=False, raise_exception=True):
19+
async def get_valid_json(self, parse_query=False, raise_exception=True):
2220
"""
2321
Make, Validate and return JSON from request BODY.
2422
@@ -33,7 +31,7 @@ def get_valid_json(self, parse_query=False, raise_exception=True):
3331
data = self.request_object.query.copy() if parse_query else {}
3432
# Get request body
3533
try:
36-
request_json = yield from self.request_object.json()
34+
request_json = await self.request_object.json()
3735
data.update(request_json)
3836
except JSONDecodeError:
3937
if raise_exception:

rest_framework/views/aiohttp/views.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Views for aiohttp.
33
44
"""
5-
import asyncio
6-
75
from aiohttp.hdrs import METH_ALL
86
from aiohttp.web import (
97
View as AioHttpClassBaseView,
@@ -43,8 +41,7 @@ def current_request_method(self):
4341
"""
4442
return self.request.method
4543

46-
@asyncio.coroutine
47-
def _iter(self):
44+
async def _iter(self):
4845
"""
4946
Iter for request handler.
5047
@@ -58,22 +55,21 @@ def _iter(self):
5855
self._raise_allowed_methods()
5956

6057
if self.use_dispatch:
61-
response = yield from self._dispatch(method)
58+
response = await self._dispatch(method)
6259
else:
63-
response = yield from method()
60+
response = await method()
6461

6562
return response
6663

67-
@asyncio.coroutine
68-
def _dispatch(self, method, *args, **kwargs):
64+
async def _dispatch(self, method, *args, **kwargs):
6965
"""
7066
Code after, before call request handler.
7167
7268
:param function method: Method handler for call.
7369
7470
"""
7571
try:
76-
result = yield from method()
72+
result = await method()
7773
return result
7874
except ApiException as e:
7975
# TODO: Not security. e.detail maybe anything

0 commit comments

Comments
 (0)