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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
d8853365
Commit
d8853365
authored
7 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make internal marker types awaitable in older Python versions
parent
cd70846b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
Cython/Utility/AsyncGen.c
Cython/Utility/AsyncGen.c
+5
-0
tests/run/test_asyncgen.py
tests/run/test_asyncgen.py
+15
-2
No files found.
Cython/Utility/AsyncGen.c
View file @
d8853365
...
...
@@ -113,6 +113,9 @@ PyDoc_STRVAR(__Pyx_async_gen_throw_doc,
"throw(typ[,val[,tb]]) -> raise exception in generator,
\n
\
return next yielded value or raise StopIteration."
);
PyDoc_STRVAR
(
__Pyx_async_gen_await_doc
,
"__await__() -> return a representation that can be passed into the 'await' expression."
);
// COPY STARTS HERE:
static
PyObject
*
__Pyx_async_gen_asend_new
(
__pyx_PyAsyncGenObject
*
,
PyObject
*
);
...
...
@@ -535,6 +538,7 @@ static PyMethodDef __Pyx_async_gen_asend_methods[] = {
{
"send"
,
(
PyCFunction
)
__Pyx_async_gen_asend_send
,
METH_O
,
__Pyx_async_gen_send_doc
},
{
"throw"
,
(
PyCFunction
)
__Pyx_async_gen_asend_throw
,
METH_VARARGS
,
__Pyx_async_gen_throw_doc
},
{
"close"
,
(
PyCFunction
)
__Pyx_async_gen_asend_close
,
METH_NOARGS
,
__Pyx_async_gen_close_doc
},
{
"__await__"
,
(
PyCFunction
)
PyObject_SelfIter
,
METH_NOARGS
,
__Pyx_async_gen_await_doc
},
{
0
,
0
,
0
,
0
}
/* Sentinel */
};
...
...
@@ -921,6 +925,7 @@ static PyMethodDef __Pyx_async_gen_athrow_methods[] = {
{
"send"
,
(
PyCFunction
)
__Pyx_async_gen_athrow_send
,
METH_O
,
__Pyx_async_gen_send_doc
},
{
"throw"
,
(
PyCFunction
)
__Pyx_async_gen_athrow_throw
,
METH_VARARGS
,
__Pyx_async_gen_throw_doc
},
{
"close"
,
(
PyCFunction
)
__Pyx_async_gen_athrow_close
,
METH_NOARGS
,
__Pyx_async_gen_close_doc
},
{
"__await__"
,
(
PyCFunction
)
PyObject_SelfIter
,
METH_NOARGS
,
__Pyx_async_gen_await_doc
},
{
0
,
0
,
0
,
0
}
/* Sentinel */
};
...
...
This diff is collapsed.
Click to expand it.
tests/run/test_asyncgen.py
View file @
d8853365
...
...
@@ -33,6 +33,19 @@ else:
return
c
try
:
from
types
import
coroutine
as
types_coroutine
except
ImportError
:
def
types_coroutine
(
f
):
return
f
try
:
from
inspect
import
isawaitable
as
inspect_isawaitable
except
ImportError
:
def
inspect_isawaitable
(
o
):
return
hasattr
(
o
,
'__await__'
)
# compiled exec()
def
exec
(
code_string
,
l
,
g
):
from
Cython.Compiler.Errors
import
CompileError
...
...
@@ -57,7 +70,7 @@ class AwaitException(Exception):
pass
@
types
.
coroutine
@
types
_
coroutine
def
awaitable
(
*
,
throw
=
False
):
if
throw
:
yield
(
'throw'
,)
...
...
@@ -373,7 +386,7 @@ class AsyncGenTest(unittest.TestCase):
self
.
assertFalse
(
g
.
ag_running
)
#self.assertIsInstance(g.ag_code, types.CodeType)
self
.
assertTrue
(
inspect
.
isawaitable
(
g
.
aclose
()))
self
.
assertTrue
(
inspect
_
isawaitable
(
g
.
aclose
()))
@
requires_asyncio
...
...
This diff is collapsed.
Click to expand it.
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