Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a8d8a5d1
Commit
a8d8a5d1
authored
Aug 09, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix coroutine property name "cr_yieldfrom" -> "cr_await"
parent
800deb71
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
1 deletion
+47
-1
CHANGES.rst
CHANGES.rst
+5
-0
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+1
-1
tests/run/test_coroutines_pep492.pyx
tests/run/test_coroutines_pep492.pyx
+41
-0
No files found.
CHANGES.rst
View file @
a8d8a5d1
...
@@ -5,6 +5,11 @@ Cython Changelog
...
@@ -5,6 +5,11 @@ Cython Changelog
Latest changes
Latest changes
==============
==============
Bugs fixed
----------
* Misnamed coroutine property ``cr_yieldfrom`` changed to ``cr_await``
to match CPython.
0.23 (2015-08-08)
0.23 (2015-08-08)
...
...
Cython/Utility/Coroutine.c
View file @
a8d8a5d1
...
@@ -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
}
};
};
...
...
tests/run/test_coroutines_pep492.pyx
View file @
a8d8a5d1
...
@@ -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
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment