Commit c02a14ee authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.23.x'

Conflicts:
	CHANGES.rst
parents ed6f70af a8d8a5d1
...@@ -18,6 +18,16 @@ Other changes ...@@ -18,6 +18,16 @@ Other changes
------------- -------------
0.23.1 (2015-08-xx)
===================
Bugs fixed
----------
* Misnamed coroutine property ``cr_yieldfrom`` changed to ``cr_await``
to match CPython.
0.23 (2015-08-08) 0.23 (2015-08-08)
================= =================
......
...@@ -1174,7 +1174,7 @@ static PyMethodDef __pyx_Coroutine_methods[] = { ...@@ -1174,7 +1174,7 @@ static PyMethodDef __pyx_Coroutine_methods[] = {
static PyMemberDef __pyx_Coroutine_memberlist[] = { static PyMemberDef __pyx_Coroutine_memberlist[] = {
{(char *) "cr_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, {(char *) "cr_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
{(char*) "cr_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, {(char*) "cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
(char*) PyDoc_STR("object being awaited, or None")}, (char*) PyDoc_STR("object being awaited, or None")},
{0, 0, 0, 0, 0} {0, 0, 0, 0, 0}
}; };
......
...@@ -463,6 +463,14 @@ class CoroutineTest(unittest.TestCase): ...@@ -463,6 +463,14 @@ class CoroutineTest(unittest.TestCase):
def assertIn(self, member, container, msg=None): def assertIn(self, member, container, msg=None):
self.assertTrue(member in container, msg) self.assertTrue(member in container, msg)
if not hasattr(unittest.TestCase, 'assertIsNone'):
def assertIsNone(self, value, msg=None):
self.assertTrue(value is None, msg)
if not hasattr(unittest.TestCase, 'assertIsNotNone'):
def assertIsNotNone(self, value, msg=None):
self.assertTrue(value is not None, msg)
def test_gen_1(self): def test_gen_1(self):
def gen(): yield def gen(): yield
self.assertFalse(hasattr(gen, '__await__')) self.assertFalse(hasattr(gen, '__await__'))
...@@ -684,6 +692,39 @@ class CoroutineTest(unittest.TestCase): ...@@ -684,6 +692,39 @@ class CoroutineTest(unittest.TestCase):
"coroutine ignored GeneratorExit"): "coroutine ignored GeneratorExit"):
c.close() c.close()
def test_cr_await(self):
@types_coroutine
def a():
#self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_RUNNING)
self.assertIsNone(coro_b.cr_await)
yield
#self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_RUNNING)
# FIXME: no idea why the following works in CPython:
#self.assertIsNone(coro_b.cr_await)
async def c():
await a()
async def b():
self.assertIsNone(coro_b.cr_await)
await c()
self.assertIsNone(coro_b.cr_await)
coro_b = b()
#self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_CREATED)
self.assertIsNone(coro_b.cr_await)
coro_b.send(None)
#self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_SUSPENDED)
#self.assertEqual(coro_b.cr_await.cr_await.gi_code.co_name, 'a')
self.assertIsNotNone(coro_b.cr_await.cr_await)
self.assertEqual(coro_b.cr_await.cr_await.__name__, 'a')
with self.assertRaises(StopIteration):
coro_b.send(None) # complete coroutine
#self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_CLOSED)
self.assertIsNone(coro_b.cr_await)
def test_corotype_1(self): def test_corotype_1(self):
async def f(): pass async def f(): pass
ct = type(f()) ct = type(f())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment