cpython: 2729823525fe (original) (raw)
Mercurial > cpython
changeset 90324:2729823525fe 3.4
asyncio.tasks: Make sure CoroWrapper.send proxies one argument correctly Issue #21209. [#21209]
Yury Selivanov yselivanov@sprymix.com | |
---|---|
date | Tue, 15 Apr 2014 12:01:16 -0400 |
parents | 4c65f8641d89 |
children | 4ab2d8fac52b ebb9595af548 |
files | Lib/asyncio/tasks.py Lib/test/test_asyncio/test_tasks.py |
diffstat | 2 files changed, 20 insertions(+), 0 deletions(-)[+] [-] Lib/asyncio/tasks.py 2 Lib/test/test_asyncio/test_tasks.py 18 |
line wrap: on
line diff
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -53,6 +53,8 @@ class CoroWrapper:
# We use *value
because of a bug in CPythons prior
# to 3.4.1. See issue #21209 and test_yield_from_corowrapper
# for details. This workaround should be removed in 3.5.0.
if len(value) == 1:[](#l1.7)
value = value[0][](#l1.8) return self.gen.send(value)[](#l1.9)
--- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -1410,6 +1410,24 @@ class TaskTests(unittest.TestCase): finally: asyncio.tasks._DEBUG = old_debug
- def test_yield_from_corowrapper_send(self):
def foo():[](#l2.8)
a = yield[](#l2.9)
return a[](#l2.10)
def call(arg):[](#l2.12)
cw = asyncio.tasks.CoroWrapper(foo(), foo)[](#l2.13)
cw.send(None)[](#l2.14)
try:[](#l2.15)
cw.send(arg)[](#l2.16)
except StopIteration as ex:[](#l2.17)
return ex.args[0][](#l2.18)
else:[](#l2.19)
raise AssertionError('StopIteration was expected')[](#l2.20)
self.assertEqual(call((1, 2)), (1, 2))[](#l2.22)
self.assertEqual(call('spam'), 'spam')[](#l2.23)