Skip to content

Commit

Permalink
fix for session.close coro in py3.4 (#2052)
Browse files Browse the repository at this point in the history
* fix for session.close coro in py3.4

* spelling fix
  • Loading branch information
thehesiod authored and asvetlov committed Jul 4, 2017
1 parent 7183dc8 commit 97db67b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changes
=======

2.2.3 (2017-07-04)
==================

- Fix `_CoroGuard` for python 3.4

2.2.2 (2017-07-03)
------------------

Expand Down
9 changes: 9 additions & 0 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(self, coro, msg):
self._msg = msg
self._awaited = False

@asyncio.coroutine
def __iter__(self):
self._awaited = True
return self._coro.__iter__()
Expand All @@ -77,6 +78,14 @@ def __del__(self):
warnings.warn(self._msg, DeprecationWarning)


if not PY_35:
try:
from asyncio import coroutines
coroutines._COROUTINE_TYPES += (_CoroGuard,)
except: # pragma: no cover
pass # Python 3.4.2 and 3.4.3 has no coroutines._COROUTINE_TYPES


coroutines = asyncio.coroutines
old_debug = coroutines._DEBUG
coroutines._DEBUG = False
Expand Down
5 changes: 5 additions & 0 deletions tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def params():
read_until_eof=False)


def test_close_coro(create_session, loop):
session = create_session()
loop.run_until_complete(session.close())


@asyncio.coroutine
def test_close_deprecated(create_session):
session = create_session()
Expand Down

0 comments on commit 97db67b

Please sign in to comment.