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
76be61a6
Commit
76be61a6
authored
Sep 04, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adapt and escape all copied AsyncGen code for Cython
parent
21cd57ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
477 additions
and
226 deletions
+477
-226
Cython/Utility/AsyncGen.c
Cython/Utility/AsyncGen.c
+377
-202
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+100
-24
No files found.
Cython/Utility/AsyncGen.c
View file @
76be61a6
/* ========= Asynchronous Generators ========= */
// This is copied from genobject.c in CPython 3.6.
// Try to keep it in sync.
//////////////////// AsyncGenerator.proto ////////////////////
//@requires: Coroutine.c::Coroutine
#define __Pyx_AsyncGen_USED
typedef
struct
{
__pyx_CoroutineObject
coro
;
PyObject
*
ag_finalizer
;
int
ag_hooks_inited
;
int
ag_closed
;
}
__pyx_AsyncGenObject
;
static
PyTypeObject
*
__pyx__PyAsyncGenWrappedValueType
=
0
;
static
PyTypeObject
*
__pyx__PyAsyncGenASendType
=
0
;
static
PyTypeObject
*
__pyx__PyAsyncGenAThrowType
=
0
;
static
PyTypeObject
*
__pyx_AsyncGenType
=
0
;
#define __Pyx_AsyncGen_CheckExact(obj) (Py_TYPE(obj) == __pyx_AsyncGenType)
#define __Pyx_AsyncGen_New(body, closure, name, qualname, module_name) \
__Pyx__Coroutine_New(__pyx_AsyncGenType, body, closure, name, qualname, module_name)
static
int
__pyx_AsyncGen_init
(
void
);
//////////////////// AsyncGeneratorSpecial ////////////////////
// this is separated out because it needs more adaptation
#if PY_VERSION_HEX < 0x030600B0
static
int
__Pyx_async_gen_init_finalizer
(
__pyx_AsyncGenObject
*
o
)
{
#if 0
PyThreadState *tstate;
#endif
PyObject
*
finalizer
;
PyObject
*
firstiter
;
if
(
o
->
ag_hooks_inited
)
{
return
0
;
}
o
->
ag_hooks_inited
=
1
;
#if 0
tstate = PyThreadState_GET();
finalizer = tstate->async_gen_finalizer;
if (finalizer) {
Py_INCREF(finalizer);
o->ag_finalizer = finalizer;
}
firstiter = tstate->async_gen_firstiter;
#endif
if
(
firstiter
)
{
PyObject
*
res
;
Py_INCREF
(
firstiter
);
res
=
__Pyx_PyObject_CallOneArg
(
firstiter
,
(
PyObject
*
)
o
);
Py_DECREF
(
firstiter
);
if
(
res
==
NULL
)
{
return
1
;
}
Py_DECREF
(
res
);
}
return
0
;
}
#endif
//////////////////// AsyncGenerator ////////////////////
//@requires: AsyncGeneratorSpecial
//@requires: Coroutine.c::Coroutine
PyDoc_STRVAR
(
__Pyx_async_gen_send_doc
,
"send(arg) -> send 'arg' into generator,
\n
\
return next yielded value or raise StopIteration."
);
PyDoc_STRVAR
(
__Pyx_async_gen_close_doc
,
"close() -> raise GeneratorExit inside generator."
);
PyDoc_STRVAR
(
__Pyx_async_gen_throw_doc
,
"throw(typ[,val[,tb]]) -> raise exception in generator,
\n
\
return next yielded value or raise StopIteration."
);
// COPY STARTS HERE:
static
PyObject
*
__Pyx_async_gen_asend_new
(
__pyx_AsyncGenObject
*
,
PyObject
*
);
static
PyObject
*
__Pyx_async_gen_athrow_new
(
__pyx_AsyncGenObject
*
,
PyObject
*
);
static
const
char
*
__Pyx_NON_INIT_CORO_MSG
=
"can't send non-None value to a just-started coroutine"
;
static
const
char
*
__Pyx_ASYNC_GEN_IGNORED_EXIT_MSG
=
"async generator ignored GeneratorExit"
;
typedef
struct
{
PyObject_HEAD
Py
AsyncGenObject
*
aw_gen
;
__pyx_
AsyncGenObject
*
aw_gen
;
PyObject
*
aw_sendval
;
int
aw_state
;
}
PyAsyncGenASend
;
}
__pyx_
PyAsyncGenASend
;
typedef
struct
{
PyObject_HEAD
Py
AsyncGenObject
*
ac_gen
;
__pyx_
AsyncGenObject
*
ac_gen
;
PyObject
*
ac_args
;
int
ac_state
;
}
PyAsyncGenAThrow
;
}
__pyx_
PyAsyncGenAThrow
;
typedef
struct
{
PyObject_HEAD
PyObject
*
val
;
}
_PyAsyncGenWrappedValue
;
}
_
_pyx__
PyAsyncGenWrappedValue
;
#ifndef _PyAsyncGen_MAXFREELIST
...
...
@@ -33,37 +127,38 @@ typedef struct {
__anext__ call.
*/
static
_
PyAsyncGenWrappedValue
*
ag_value_fl
[
_PyAsyncGen_MAXFREELIST
];
static
int
ag_value_fl_free
=
0
;
static
_
_pyx__PyAsyncGenWrappedValue
*
__Pyx_
ag_value_fl
[
_PyAsyncGen_MAXFREELIST
];
static
int
__Pyx_
ag_value_fl_free
=
0
;
static
PyAsyncGenASend
*
ag_asend_fl
[
_PyAsyncGen_MAXFREELIST
];
static
int
ag_asend_fl_free
=
0
;
static
__pyx_PyAsyncGenASend
*
__Pyx_
ag_asend_fl
[
_PyAsyncGen_MAXFREELIST
];
static
int
__Pyx_
ag_asend_fl_free
=
0
;
#define _PyAsyncGenWrappedValue_CheckExact(o) \
(Py_TYPE(o) ==
&_PyAsyncGenWrappedValue_
Type)
#define _
_pyx__
PyAsyncGenWrappedValue_CheckExact(o) \
(Py_TYPE(o) ==
__pyx__PyAsyncGenWrappedValue
Type)
#define PyAsyncGenASend_CheckExact(o) \
(Py_TYPE(o) ==
&_PyAsyncGenASend_
Type)
#define
__pyx_
PyAsyncGenASend_CheckExact(o) \
(Py_TYPE(o) ==
__pyx__PyAsyncGenASend
Type)
static
int
async_gen_traverse
(
Py
AsyncGenObject
*
gen
,
visitproc
visit
,
void
*
arg
)
__Pyx_async_gen_traverse
(
__pyx_
AsyncGenObject
*
gen
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
gen
->
ag_finalizer
);
return
gen_traverse
((
PyGen
Object
*
)
gen
,
visit
,
arg
);
return
__Pyx_Coroutine_traverse
((
__pyx_Coroutine
Object
*
)
gen
,
visit
,
arg
);
}
static
PyObject
*
async_gen_repr
(
PyAsyncGen
Object
*
o
)
__Pyx_async_gen_repr
(
__pyx_Coroutine
Object
*
o
)
{
return
PyUnicode_FromFormat
(
"<async_generator object %S at %p>"
,
o
->
ag
_qualname
,
o
);
o
->
gi
_qualname
,
o
);
}
#if PY_VERSION_HEX >= 0x030600B0
static
int
async_gen_init_finalizer
(
Py
AsyncGenObject
*
o
)
__Pyx_async_gen_init_finalizer
(
__pyx_
AsyncGenObject
*
o
)
{
PyThreadState
*
tstate
;
PyObject
*
finalizer
;
...
...
@@ -88,7 +183,7 @@ async_gen_init_finalizer(PyAsyncGenObject *o)
PyObject
*
res
;
Py_INCREF
(
firstiter
);
res
=
PyObject_CallFunction
(
firstiter
,
"O"
,
o
);
res
=
__Pyx_PyObject_CallOneArg
(
firstiter
,
(
PyObject
*
)
o
);
Py_DECREF
(
firstiter
);
if
(
res
==
NULL
)
{
return
1
;
...
...
@@ -98,121 +193,133 @@ async_gen_init_finalizer(PyAsyncGenObject *o)
return
0
;
}
#endif
static
PyObject
*
async_gen_anext
(
Py
AsyncGenObject
*
o
)
__Pyx_async_gen_anext
(
__pyx_
AsyncGenObject
*
o
)
{
if
(
async_gen_init_finalizer
(
o
))
{
if
(
__Pyx_
async_gen_init_finalizer
(
o
))
{
return
NULL
;
}
return
async_gen_asend_new
(
o
,
NULL
);
return
__Pyx_
async_gen_asend_new
(
o
,
NULL
);
}
static
PyObject
*
async_gen_asend
(
Py
AsyncGenObject
*
o
,
PyObject
*
arg
)
__Pyx_async_gen_asend
(
__pyx_
AsyncGenObject
*
o
,
PyObject
*
arg
)
{
if
(
async_gen_init_finalizer
(
o
))
{
if
(
__Pyx_
async_gen_init_finalizer
(
o
))
{
return
NULL
;
}
return
async_gen_asend_new
(
o
,
arg
);
return
__Pyx_
async_gen_asend_new
(
o
,
arg
);
}
static
PyObject
*
async_gen_aclose
(
PyAsyncGenObject
*
o
,
PyObject
*
arg
)
__Pyx_async_gen_aclose
(
__pyx_AsyncGenObject
*
o
,
CYTHON_UNUSED
PyObject
*
arg
)
{
if
(
async_gen_init_finalizer
(
o
))
{
if
(
__Pyx_
async_gen_init_finalizer
(
o
))
{
return
NULL
;
}
return
async_gen_athrow_new
(
o
,
NULL
);
return
__Pyx_
async_gen_athrow_new
(
o
,
NULL
);
}
static
PyObject
*
async_gen_athrow
(
Py
AsyncGenObject
*
o
,
PyObject
*
args
)
__Pyx_async_gen_athrow
(
__pyx_
AsyncGenObject
*
o
,
PyObject
*
args
)
{
if
(
async_gen_init_finalizer
(
o
))
{
if
(
__Pyx_
async_gen_init_finalizer
(
o
))
{
return
NULL
;
}
return
async_gen_athrow_new
(
o
,
args
);
return
__Pyx_
async_gen_athrow_new
(
o
,
args
);
}
static
PyGetSetDef
async_gen_getsetlist
[]
=
{
{
"__name__"
,
(
getter
)
gen_get_name
,
(
setter
)
gen
_set_name
,
PyDoc_STR
(
"name of the async generator"
)},
{
"__qualname__"
,
(
getter
)
gen_get_qualname
,
(
setter
)
gen_s
et_qualname
,
PyDoc_STR
(
"qualified name of the async generator"
)},
{
"ag_await"
,
(
getter
)
coro_get_cr_await
,
NULL
,
PyDoc_STR
(
"object being awaited on, or None"
)},
{
NULL
}
/* Sentinel */
static
PyGetSetDef
__Pyx_
async_gen_getsetlist
[]
=
{
{
"__name__"
,
(
getter
)
__Pyx_Coroutine_get_name
,
(
setter
)
__Pyx_Coroutine
_set_name
,
PyDoc_STR
(
"name of the async generator"
)
,
0
},
{
"__qualname__"
,
(
getter
)
__Pyx_Coroutine_get_qualname
,
(
setter
)
__Pyx_Coroutine_g
et_qualname
,
PyDoc_STR
(
"qualified name of the async generator"
)
,
0
},
//REMOVED:
{"ag_await", (getter)coro_get_cr_await, NULL,
//REMOVED:
PyDoc_STR("object being awaited on, or None")},
{
0
,
0
,
0
,
0
,
0
}
/* Sentinel */
};
static
PyMemberDef
async_gen_memberlist
[]
=
{
{
"ag_frame"
,
T_OBJECT
,
offsetof
(
PyAsyncGenObject
,
ag_frame
),
READONLY
},
{
"ag_running"
,
T_BOOL
,
offsetof
(
PyAsyncGenObject
,
ag_running
),
READONLY
},
{
"ag_code"
,
T_OBJECT
,
offsetof
(
PyAsyncGenObject
,
ag_code
),
READONLY
},
{
NULL
}
/* Sentinel */
static
PyMemberDef
__Pyx_async_gen_memberlist
[]
=
{
//REMOVED: {"ag_frame", T_OBJECT, offsetof(__pyx_AsyncGenObject, ag_frame), READONLY},
{
"ag_running"
,
T_BOOL
,
offsetof
(
__pyx_CoroutineObject
,
is_running
),
READONLY
,
NULL
},
//REMOVED: {"ag_code", T_OBJECT, offsetof(__pyx_AsyncGenObject, ag_code), READONLY},
//ADDED: "ag_await"
{(
char
*
)
"ag_await"
,
T_OBJECT
,
offsetof
(
__pyx_CoroutineObject
,
yieldfrom
),
READONLY
,
(
char
*
)
PyDoc_STR
(
"object being awaited on, or None"
)},
{
0
,
0
,
0
,
0
,
0
}
/* Sentinel */
};
PyDoc_STRVAR
(
async_aclose_doc
,
PyDoc_STRVAR
(
__Pyx_
async_aclose_doc
,
"aclose() -> raise GeneratorExit inside generator."
);
PyDoc_STRVAR
(
async_asend_doc
,
PyDoc_STRVAR
(
__Pyx_
async_asend_doc
,
"asend(v) -> send 'v' in generator."
);
PyDoc_STRVAR
(
async_athrow_doc
,
PyDoc_STRVAR
(
__Pyx_
async_athrow_doc
,
"athrow(typ[,val[,tb]]) -> raise exception in generator."
);
static
PyMethodDef
async_gen_methods
[]
=
{
{
"asend"
,
(
PyCFunction
)
async_gen_asend
,
METH_O
,
async_asend_doc
},
{
"athrow"
,(
PyCFunction
)
async_gen_athrow
,
METH_VARARGS
,
async_athrow_doc
},
{
"aclose"
,
(
PyCFunction
)
async_gen_aclose
,
METH_NOARGS
,
async_aclose_doc
},
{
NULL
,
NULL
}
/* Sentinel */
static
PyMethodDef
__Pyx_
async_gen_methods
[]
=
{
{
"asend"
,
(
PyCFunction
)
__Pyx_async_gen_asend
,
METH_O
,
__Pyx_
async_asend_doc
},
{
"athrow"
,(
PyCFunction
)
__Pyx_async_gen_athrow
,
METH_VARARGS
,
__Pyx_
async_athrow_doc
},
{
"aclose"
,
(
PyCFunction
)
__Pyx_async_gen_aclose
,
METH_NOARGS
,
__Pyx_
async_aclose_doc
},
{
0
,
0
,
0
,
0
}
/* Sentinel */
};
static
PyAsyncMethods
async_gen_as_async
=
{
static
PyAsyncMethods
__Pyx_
async_gen_as_async
=
{
0
,
/* am_await */
PyObject_SelfIter
,
/* am_aiter */
(
unaryfunc
)
async_gen_anext
/* am_anext */
(
unaryfunc
)
__Pyx_async_gen_anext
/* am_anext */
};
PyTypeObject
PyAsyncGen_T
ype
=
{
PyTypeObject
__pyx_AsyncGenType_t
ype
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
"async_generator"
,
/* tp_name */
sizeof
(
Py
AsyncGenObject
),
/* tp_basicsize */
sizeof
(
__pyx_
AsyncGenObject
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
gen
_dealloc
,
/* tp_dealloc */
(
destructor
)
__Pyx_Coroutine_check_and
_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
&
async_gen_as_async
,
/* tp_as_async */
(
reprfunc
)
async_gen_repr
,
/* tp_repr */
#if CYTHON_USE_ASYNC_SLOTS
&
__Pyx_async_gen_as_async
,
/* tp_as_async */
#else
0
,
/*tp_reserved*/
#endif
(
reprfunc
)
__Pyx_async_gen_repr
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_HAVE_FINALIZE
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_HAVE_FINALIZE
,
/* tp_flags */
0
,
/* tp_doc */
(
traverseproc
)
async_gen_traverse
,
/* tp_traverse */
(
traverseproc
)
__Pyx_
async_gen_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
offsetof
(
PyAsyncGenObject
,
ag_weakreflist
),
/* tp_weaklistoffset */
#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
// in order to (mis-)use tp_reserved above, we must also implement tp_richcompare
__Pyx_Coroutine_compare
,
/*tp_richcompare*/
#else
0
,
/*tp_richcompare*/
#endif
offsetof
(
__pyx_CoroutineObject
,
gi_weakreflist
),
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
async_gen_methods
,
/* tp_methods */
async_gen_memberlist
,
/* tp_members */
async_gen_getsetlist
,
/* tp_getset */
__Pyx_
async_gen_methods
,
/* tp_methods */
__Pyx_
async_gen_memberlist
,
/* tp_members */
__Pyx_
async_gen_getsetlist
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
...
...
@@ -228,66 +335,56 @@ PyTypeObject PyAsyncGen_Type = {
0
,
/* tp_cache */
0
,
/* tp_subclasses */
0
,
/* tp_weaklist */
0
,
/* tp_del */
#if PY_VERSION_HEX >= 0x030400a1
0
,
/*tp_del*/
#else
__Pyx_Coroutine_del
,
/*tp_del*/
#endif
0
,
/* tp_version_tag */
_PyGen_Finalize
,
/* tp_finalize */
#if PY_VERSION_HEX >= 0x030400a1
__Pyx_Coroutine_del
,
/* tp_finalize */
#endif
};
PyObject
*
PyAsyncGen_New
(
PyFrameObject
*
f
,
PyObject
*
name
,
PyObject
*
qualname
)
{
PyAsyncGenObject
*
o
;
o
=
(
PyAsyncGenObject
*
)
gen_new_with_qualname
(
&
PyAsyncGen_Type
,
f
,
name
,
qualname
);
if
(
o
==
NULL
)
{
return
NULL
;
}
o
->
ag_finalizer
=
NULL
;
o
->
ag_closed
=
0
;
o
->
ag_hooks_inited
=
0
;
return
(
PyObject
*
)
o
;
}
int
PyAsyncGen_ClearFreeLists
(
void
)
static
int
__Pyx_PyAsyncGen_ClearFreeLists
(
void
)
{
int
ret
=
ag_value_fl_free
+
ag_asend_fl_free
;
int
ret
=
__Pyx_ag_value_fl_free
+
__Pyx_
ag_asend_fl_free
;
while
(
ag_value_fl_free
)
{
_PyAsyncGenWrappedValue
*
o
;
o
=
ag_value_fl
[
--
ag_value_fl_free
];
assert
(
_PyAsyncGenWrappedValue_CheckExact
(
o
));
while
(
__Pyx_
ag_value_fl_free
)
{
_
_pyx__
PyAsyncGenWrappedValue
*
o
;
o
=
__Pyx_ag_value_fl
[
--
__Pyx_
ag_value_fl_free
];
assert
(
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
o
));
PyObject_Del
(
o
);
}
while
(
ag_asend_fl_free
)
{
PyAsyncGenASend
*
o
;
o
=
ag_asend_fl
[
--
ag_asend_fl_free
];
assert
(
Py_TYPE
(
o
)
==
&
_PyAsyncGenASend_
Type
);
while
(
__Pyx_
ag_asend_fl_free
)
{
__pyx_
PyAsyncGenASend
*
o
;
o
=
__Pyx_ag_asend_fl
[
--
__Pyx_
ag_asend_fl_free
];
assert
(
Py_TYPE
(
o
)
==
__pyx__PyAsyncGenASend
Type
);
PyObject_Del
(
o
);
}
return
ret
;
}
void
PyAsyncGen_Fini
(
void
)
static
void
__Pyx_
PyAsyncGen_Fini
(
void
)
{
PyAsyncGen_ClearFreeLists
();
__Pyx_
PyAsyncGen_ClearFreeLists
();
}
static
PyObject
*
async_gen_unwrap_value
(
Py
AsyncGenObject
*
gen
,
PyObject
*
result
)
__Pyx_async_gen_unwrap_value
(
__pyx_
AsyncGenObject
*
gen
,
PyObject
*
result
)
{
if
(
result
==
NULL
)
{
if
(
!
PyErr_Occurred
())
{
PyErr_SetNone
(
PyExc_StopAsyncIteration
);
PyErr_SetNone
(
__Pyx_
PyExc_StopAsyncIteration
);
}
if
(
PyErr_ExceptionMatches
(
PyExc_StopAsyncIteration
)
if
(
PyErr_ExceptionMatches
(
__Pyx_
PyExc_StopAsyncIteration
)
||
PyErr_ExceptionMatches
(
PyExc_GeneratorExit
)
)
{
gen
->
ag_closed
=
1
;
...
...
@@ -296,12 +393,11 @@ async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result)
return
NULL
;
}
if
(
_PyAsyncGenWrappedValue_CheckExact
(
result
))
{
if
(
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
result
))
{
/* async yield */
PyObject
*
e
=
PyObject_CallFunctionObjArgs
(
PyObject
*
e
=
__Pyx_PyObject_CallOneArg
(
PyExc_StopIteration
,
((
_PyAsyncGenWrappedValue
*
)
result
)
->
val
,
NULL
);
((
__pyx__PyAsyncGenWrappedValue
*
)
result
)
->
val
);
Py_DECREF
(
result
);
PyErr_SetObject
(
PyExc_StopIteration
,
e
);
Py_DECREF
(
e
);
...
...
@@ -316,13 +412,13 @@ async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result)
static
void
async_gen_asend_dealloc
(
PyAsyncGenASend
*
o
)
__Pyx_async_gen_asend_dealloc
(
__pyx_
PyAsyncGenASend
*
o
)
{
Py_CLEAR
(
o
->
aw_gen
);
Py_CLEAR
(
o
->
aw_sendval
);
if
(
ag_asend_fl_free
<
_PyAsyncGen_MAXFREELIST
)
{
assert
(
PyAsyncGenASend_CheckExact
(
o
));
ag_asend_fl
[
ag_asend_fl_free
++
]
=
o
;
if
(
__Pyx_
ag_asend_fl_free
<
_PyAsyncGen_MAXFREELIST
)
{
assert
(
__pyx_
PyAsyncGenASend_CheckExact
(
o
));
__Pyx_ag_asend_fl
[
__Pyx_
ag_asend_fl_free
++
]
=
o
;
}
else
{
PyObject_Del
(
o
);
}
...
...
@@ -330,7 +426,7 @@ async_gen_asend_dealloc(PyAsyncGenASend *o)
static
PyObject
*
async_gen_asend_send
(
PyAsyncGenASend
*
o
,
PyObject
*
arg
)
__Pyx_async_gen_asend_send
(
__pyx_
PyAsyncGenASend
*
o
,
PyObject
*
arg
)
{
PyObject
*
result
;
...
...
@@ -346,8 +442,8 @@ async_gen_asend_send(PyAsyncGenASend *o, PyObject *arg)
o
->
aw_state
=
1
;
}
result
=
gen_send_ex
((
PyGenObject
*
)
o
->
aw_gen
,
arg
,
0
,
0
);
result
=
async_gen_unwrap_value
(
o
->
aw_gen
,
result
);
result
=
__Pyx_Coroutine_SendEx
((
__pyx_CoroutineObject
*
)
o
->
aw_gen
,
arg
);
result
=
__Pyx_
async_gen_unwrap_value
(
o
->
aw_gen
,
result
);
if
(
result
==
NULL
)
{
o
->
aw_state
=
2
;
...
...
@@ -358,14 +454,14 @@ async_gen_asend_send(PyAsyncGenASend *o, PyObject *arg)
static
PyObject
*
async_gen_asend_iternext
(
PyAsyncGenASend
*
o
)
__Pyx_async_gen_asend_iternext
(
__pyx_
PyAsyncGenASend
*
o
)
{
return
async_gen_asend_send
(
o
,
NULL
);
return
__Pyx_
async_gen_asend_send
(
o
,
NULL
);
}
static
PyObject
*
async_gen_asend_throw
(
PyAsyncGenASend
*
o
,
PyObject
*
args
)
__Pyx_async_gen_asend_throw
(
__pyx_
PyAsyncGenASend
*
o
,
PyObject
*
args
)
{
PyObject
*
result
;
...
...
@@ -374,8 +470,8 @@ async_gen_asend_throw(PyAsyncGenASend *o, PyObject *args)
return
NULL
;
}
result
=
gen_throw
((
PyGen
Object
*
)
o
->
aw_gen
,
args
);
result
=
async_gen_unwrap_value
(
o
->
aw_gen
,
result
);
result
=
__Pyx_Coroutine_Throw
((
Py
Object
*
)
o
->
aw_gen
,
args
);
result
=
__Pyx_
async_gen_unwrap_value
(
o
->
aw_gen
,
result
);
if
(
result
==
NULL
)
{
o
->
aw_state
=
2
;
...
...
@@ -386,39 +482,43 @@ async_gen_asend_throw(PyAsyncGenASend *o, PyObject *args)
static
PyObject
*
async_gen_asend_close
(
PyAsyncGenASend
*
o
,
PyObject
*
args
)
__Pyx_async_gen_asend_close
(
__pyx_PyAsyncGenASend
*
o
,
CYTHON_UNUSED
PyObject
*
args
)
{
o
->
aw_state
=
2
;
Py_RETURN_NONE
;
}
static
PyMethodDef
async_gen_asend_methods
[]
=
{
{
"send"
,
(
PyCFunction
)
async_gen_asend_send
,
METH_O
,
send_doc
},
{
"throw"
,
(
PyCFunction
)
async_gen_asend_throw
,
METH_VARARGS
,
throw_doc
},
{
"close"
,
(
PyCFunction
)
async_gen_asend_close
,
METH_NOARGS
,
close_doc
},
{
NULL
,
NULL
}
/* Sentinel */
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
},
{
0
,
0
,
0
,
0
}
/* Sentinel */
};
static
PyAsyncMethods
async_gen_asend_as_async
=
{
static
PyAsyncMethods
__Pyx_
async_gen_asend_as_async
=
{
PyObject_SelfIter
,
/* am_await */
0
,
/* am_aiter */
0
/* am_anext */
};
PyTypeObject
_
PyAsyncGenASend_T
ype
=
{
PyTypeObject
_
_pyx__PyAsyncGenASendType_t
ype
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
"async_generator_asend"
,
/* tp_name */
sizeof
(
PyAsyncGenASend
),
/* tp_basicsize */
sizeof
(
__pyx_
PyAsyncGenASend
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
async_gen_asend_dealloc
,
/* tp_dealloc */
(
destructor
)
__Pyx_
async_gen_asend_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
&
async_gen_asend_as_async
,
/* tp_as_async */
#if CYTHON_USE_ASYNC_SLOTS
&
__Pyx_async_gen_asend_as_async
,
/* tp_as_async */
#else
0
,
/*tp_reserved*/
#endif
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
...
...
@@ -433,11 +533,16 @@ PyTypeObject _PyAsyncGenASend_Type = {
0
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
// in order to (mis-)use tp_reserved above, we must also implement tp_richcompare
__Pyx_Coroutine_compare
,
/*tp_richcompare*/
#else
0
,
/*tp_richcompare*/
#endif
0
,
/* tp_weaklistoffset */
PyObject_SelfIter
,
/* tp_iter */
(
iternextfunc
)
async_gen_asend_iternext
,
/* tp_iternext */
async_gen_asend_methods
,
/* tp_methods */
(
iternextfunc
)
__Pyx_
async_gen_asend_iternext
,
/* tp_iternext */
__Pyx_
async_gen_asend_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
...
...
@@ -448,19 +553,31 @@ PyTypeObject _PyAsyncGenASend_Type = {
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
0
,
/* tp_free */
0
,
/* tp_is_gc */
0
,
/* tp_bases */
0
,
/* tp_mro */
0
,
/* tp_cache */
0
,
/* tp_subclasses */
0
,
/* tp_weaklist */
0
,
/* tp_del */
0
,
/* tp_version_tag */
#if PY_VERSION_HEX >= 0x030400a1
0
,
/* tp_finalize */
#endif
};
static
PyObject
*
async_gen_asend_new
(
Py
AsyncGenObject
*
gen
,
PyObject
*
sendval
)
__Pyx_async_gen_asend_new
(
__pyx_
AsyncGenObject
*
gen
,
PyObject
*
sendval
)
{
PyAsyncGenASend
*
o
;
if
(
ag_asend_fl_free
)
{
ag_asend_fl_free
--
;
o
=
ag_asend_fl
[
ag_asend_fl_free
];
__pyx_
PyAsyncGenASend
*
o
;
if
(
__Pyx_
ag_asend_fl_free
)
{
__Pyx_
ag_asend_fl_free
--
;
o
=
__Pyx_ag_asend_fl
[
__Pyx_
ag_asend_fl_free
];
_Py_NewReference
((
PyObject
*
)
o
);
}
else
{
o
=
PyObject_New
(
PyAsyncGenASend
,
&
_PyAsyncGenASend_
Type
);
o
=
PyObject_New
(
__pyx_PyAsyncGenASend
,
__pyx__PyAsyncGenASend
Type
);
if
(
o
==
NULL
)
{
return
NULL
;
}
...
...
@@ -478,25 +595,25 @@ async_gen_asend_new(PyAsyncGenObject *gen, PyObject *sendval)
static
void
async_gen_wrapped_val_dealloc
(
_PyAsyncGenWrappedValue
*
o
)
__Pyx_async_gen_wrapped_val_dealloc
(
__pyx_
_PyAsyncGenWrappedValue
*
o
)
{
Py_CLEAR
(
o
->
val
);
if
(
ag_value_fl_free
<
_PyAsyncGen_MAXFREELIST
)
{
assert
(
_PyAsyncGenWrappedValue_CheckExact
(
o
));
ag_value_fl
[
ag_value_fl_free
++
]
=
o
;
if
(
__Pyx_
ag_value_fl_free
<
_PyAsyncGen_MAXFREELIST
)
{
assert
(
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
o
));
__Pyx_ag_value_fl
[
__Pyx_
ag_value_fl_free
++
]
=
o
;
}
else
{
PyObject_Del
(
o
);
}
}
PyTypeObject
_
PyAsyncGenWrappedValue_T
ype
=
{
PyTypeObject
_
_pyx__PyAsyncGenWrappedValueType_t
ype
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
"async_generator_wrapped_value"
,
/* tp_name */
sizeof
(
_PyAsyncGenWrappedValue
),
/* tp_basicsize */
sizeof
(
_
_pyx__
PyAsyncGenWrappedValue
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
async_gen_wrapped_val_dealloc
,
/* tp_dealloc */
(
destructor
)
__Pyx_
async_gen_wrapped_val_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
...
...
@@ -530,22 +647,34 @@ PyTypeObject _PyAsyncGenWrappedValue_Type = {
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
0
,
/* tp_free */
0
,
/* tp_is_gc */
0
,
/* tp_bases */
0
,
/* tp_mro */
0
,
/* tp_cache */
0
,
/* tp_subclasses */
0
,
/* tp_weaklist */
0
,
/* tp_del */
0
,
/* tp_version_tag */
#if PY_VERSION_HEX >= 0x030400a1
0
,
/* tp_finalize */
#endif
};
PyObject
*
_PyAsyncGenWrapValue
(
PyObject
*
val
)
static
PyObject
*
_
_pyx__
PyAsyncGenWrapValue
(
PyObject
*
val
)
{
_PyAsyncGenWrappedValue
*
o
;
_
_pyx__
PyAsyncGenWrappedValue
*
o
;
assert
(
val
);
if
(
ag_value_fl_free
)
{
ag_value_fl_free
--
;
o
=
ag_value_fl
[
ag_value_fl_free
];
assert
(
_PyAsyncGenWrappedValue_CheckExact
(
o
));
if
(
__Pyx_
ag_value_fl_free
)
{
__Pyx_
ag_value_fl_free
--
;
o
=
__Pyx_ag_value_fl
[
__Pyx_
ag_value_fl_free
];
assert
(
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
o
));
_Py_NewReference
((
PyObject
*
)
o
);
}
else
{
o
=
PyObject_New
(
_
PyAsyncGenWrappedValue
,
&
_PyAsyncGenWrappedValue_
Type
);
o
=
PyObject_New
(
_
_pyx__PyAsyncGenWrappedValue
,
__pyx__PyAsyncGenWrappedValue
Type
);
if
(
o
==
NULL
)
{
return
NULL
;
}
...
...
@@ -560,7 +689,7 @@ _PyAsyncGenWrapValue(PyObject *val)
static
void
async_gen_athrow_dealloc
(
PyAsyncGenAThrow
*
o
)
__Pyx_async_gen_athrow_dealloc
(
__pyx_
PyAsyncGenAThrow
*
o
)
{
Py_CLEAR
(
o
->
ac_gen
);
Py_CLEAR
(
o
->
ac_args
);
...
...
@@ -569,13 +698,12 @@ async_gen_athrow_dealloc(PyAsyncGenAThrow *o)
static
PyObject
*
async_gen_athrow_send
(
PyAsyncGenAThrow
*
o
,
PyObject
*
arg
)
__Pyx_async_gen_athrow_send
(
__pyx_
PyAsyncGenAThrow
*
o
,
PyObject
*
arg
)
{
PyGenObject
*
gen
=
(
PyGenObject
*
)
o
->
ac_gen
;
PyFrameObject
*
f
=
gen
->
gi_frame
;
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
o
->
ac_gen
;
PyObject
*
retval
;
if
(
f
==
NULL
||
f
->
f_stacktop
==
NULL
||
o
->
ac_state
==
2
)
{
if
(
o
->
ac_state
==
2
)
{
PyErr_SetNone
(
PyExc_StopIteration
);
return
NULL
;
}
...
...
@@ -587,7 +715,7 @@ async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
}
if
(
arg
!=
Py_None
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
NON_INIT_CORO_MSG
);
PyErr_SetString
(
PyExc_RuntimeError
,
__Pyx_
NON_INIT_CORO_MSG
);
return
NULL
;
}
...
...
@@ -597,12 +725,12 @@ async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
/* aclose() mode */
o
->
ac_gen
->
ag_closed
=
1
;
retval
=
_
gen_throw
((
PyGenObject
*
)
gen
,
0
,
/* Do not close generator when
PyExc_GeneratorExit is passed */
PyExc_GeneratorExit
,
NULL
,
NULL
);
retval
=
_
_Pyx__Coroutine_Throw
((
PyObject
*
)
gen
,
/* Do not close generator when
PyExc_GeneratorExit is passed */
PyExc_GeneratorExit
,
NULL
,
NULL
,
NULL
,
0
);
if
(
retval
&&
_PyAsyncGenWrappedValue_CheckExact
(
retval
))
{
if
(
retval
&&
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
retval
))
{
Py_DECREF
(
retval
);
goto
yield_close
;
}
...
...
@@ -616,11 +744,11 @@ async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
return
NULL
;
}
retval
=
_
gen_throw
((
PyGenObject
*
)
gen
,
0
,
/* Do not close generator when
PyExc_GeneratorExit is passed */
typ
,
val
,
tb
);
retval
=
async_gen_unwrap_value
(
o
->
ac_gen
,
retval
);
retval
=
_
_Pyx__Coroutine_Throw
((
PyObject
*
)
gen
,
/* Do not close generator when
PyExc_GeneratorExit is passed */
typ
,
val
,
tb
,
o
->
ac_args
,
0
);
retval
=
__Pyx_
async_gen_unwrap_value
(
o
->
ac_gen
,
retval
);
}
if
(
retval
==
NULL
)
{
goto
check_error
;
...
...
@@ -629,12 +757,12 @@ async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
}
if
(
o
->
ac_state
==
1
)
{
PyObject
*
retval
=
gen_send_ex
((
PyGenObject
*
)
gen
,
arg
,
0
,
0
);
PyObject
*
retval
=
__Pyx_Coroutine_SendEx
((
__pyx_CoroutineObject
*
)
gen
,
arg
);
if
(
o
->
ac_args
)
{
return
async_gen_unwrap_value
(
o
->
ac_gen
,
retval
);
return
__Pyx_
async_gen_unwrap_value
(
o
->
ac_gen
,
retval
);
}
else
{
/* aclose() mode */
if
(
retval
&&
_PyAsyncGenWrappedValue_CheckExact
(
retval
))
{
if
(
retval
&&
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
retval
))
{
Py_DECREF
(
retval
);
goto
yield_close
;
}
...
...
@@ -649,11 +777,11 @@ async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
yield_close:
PyErr_SetString
(
PyExc_RuntimeError
,
ASYNC_GEN_IGNORED_EXIT_MSG
);
PyExc_RuntimeError
,
__Pyx_
ASYNC_GEN_IGNORED_EXIT_MSG
);
return
NULL
;
check_error:
if
(
PyErr_ExceptionMatches
(
PyExc_StopAsyncIteration
)
if
(
PyErr_ExceptionMatches
(
__Pyx_
PyExc_StopAsyncIteration
)
||
PyErr_ExceptionMatches
(
PyExc_GeneratorExit
)
)
{
o
->
ac_state
=
2
;
...
...
@@ -665,12 +793,12 @@ check_error:
static
PyObject
*
async_gen_athrow_throw
(
PyAsyncGenAThrow
*
o
,
PyObject
*
args
)
__Pyx_async_gen_athrow_throw
(
__pyx_
PyAsyncGenAThrow
*
o
,
PyObject
*
args
)
{
PyObject
*
retval
;
if
(
o
->
ac_state
==
0
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
NON_INIT_CORO_MSG
);
PyErr_SetString
(
PyExc_RuntimeError
,
__Pyx_
NON_INIT_CORO_MSG
);
return
NULL
;
}
...
...
@@ -679,14 +807,14 @@ async_gen_athrow_throw(PyAsyncGenAThrow *o, PyObject *args)
return
NULL
;
}
retval
=
gen_throw
((
PyGen
Object
*
)
o
->
ac_gen
,
args
);
retval
=
__Pyx_Coroutine_Throw
((
Py
Object
*
)
o
->
ac_gen
,
args
);
if
(
o
->
ac_args
)
{
return
async_gen_unwrap_value
(
o
->
ac_gen
,
retval
);
return
__Pyx_
async_gen_unwrap_value
(
o
->
ac_gen
,
retval
);
}
else
{
/* aclose() mode */
if
(
retval
&&
_PyAsyncGenWrappedValue_CheckExact
(
retval
))
{
if
(
retval
&&
_
_pyx__
PyAsyncGenWrappedValue_CheckExact
(
retval
))
{
Py_DECREF
(
retval
);
PyErr_SetString
(
PyExc_RuntimeError
,
ASYNC_GEN_IGNORED_EXIT_MSG
);
PyErr_SetString
(
PyExc_RuntimeError
,
__Pyx_
ASYNC_GEN_IGNORED_EXIT_MSG
);
return
NULL
;
}
return
retval
;
...
...
@@ -695,46 +823,49 @@ async_gen_athrow_throw(PyAsyncGenAThrow *o, PyObject *args)
static
PyObject
*
async_gen_athrow_iternext
(
PyAsyncGenAThrow
*
o
)
__Pyx_async_gen_athrow_iternext
(
__pyx_
PyAsyncGenAThrow
*
o
)
{
return
async_gen_athrow_send
(
o
,
Py_None
);
return
__Pyx_
async_gen_athrow_send
(
o
,
Py_None
);
}
static
PyObject
*
async_gen_athrow_close
(
PyAsyncGenAThrow
*
o
,
PyObject
*
args
)
__Pyx_async_gen_athrow_close
(
__pyx_PyAsyncGenAThrow
*
o
,
CYTHON_UNUSED
PyObject
*
args
)
{
o
->
ac_state
=
2
;
Py_RETURN_NONE
;
}
static
PyMethodDef
async_gen_athrow_methods
[]
=
{
{
"send"
,
(
PyCFunction
)
async_gen_athrow_send
,
METH_O
,
send_doc
},
{
"throw"
,
(
PyCFunction
)
async_gen_athrow_throw
,
METH_VARARGS
,
throw_doc
},
{
"close"
,
(
PyCFunction
)
async_gen_athrow_close
,
METH_NOARGS
,
close_doc
},
{
NULL
,
NULL
}
/* Sentinel */
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
},
{
0
,
0
,
0
,
0
}
/* Sentinel */
};
static
PyAsyncMethods
async_gen_athrow_as_async
=
{
static
PyAsyncMethods
__Pyx_
async_gen_athrow_as_async
=
{
PyObject_SelfIter
,
/* am_await */
0
,
/* am_aiter */
0
/* am_anext */
};
PyTypeObject
_
PyAsyncGenAThrow_T
ype
=
{
PyTypeObject
_
_pyx__PyAsyncGenAThrowType_t
ype
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
"async_generator_athrow"
,
/* tp_name */
sizeof
(
PyAsyncGenAThrow
),
/* tp_basicsize */
sizeof
(
__pyx_
PyAsyncGenAThrow
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
async_gen_athrow_dealloc
,
/* tp_dealloc */
(
destructor
)
__Pyx_async_gen_athrow_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
&
async_gen_athrow_as_async
,
/* tp_as_async */
#if CYTHON_USE_ASYNC_SLOTS
&
__Pyx_async_gen_athrow_as_async
,
/* tp_as_async */
#else
0
,
/*tp_reserved*/
#endif
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
...
...
@@ -749,11 +880,17 @@ PyTypeObject _PyAsyncGenAThrow_Type = {
0
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
// in order to (mis-)use tp_reserved above, we must also implement tp_richcompare
__Pyx_Coroutine_compare
,
/*tp_richcompare*/
#else
0
,
/*tp_richcompare*/
#endif
0
,
/* tp_weaklistoffset */
PyObject_SelfIter
,
/* tp_iter */
(
iternextfunc
)
async_gen_athrow_iternext
,
/* tp_iternext */
async_gen_athrow_methods
,
/* tp_members */
(
iternextfunc
)
__Pyx_async_gen_athrow_iternext
,
/* tp_iternext */
__Pyx_async_gen_athrow_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
...
...
@@ -763,14 +900,26 @@ PyTypeObject _PyAsyncGenAThrow_Type = {
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
0
,
/* tp_free */
0
,
/* tp_is_gc */
0
,
/* tp_bases */
0
,
/* tp_mro */
0
,
/* tp_cache */
0
,
/* tp_subclasses */
0
,
/* tp_weaklist */
0
,
/* tp_del */
0
,
/* tp_version_tag */
#if PY_VERSION_HEX >= 0x030400a1
0
,
/* tp_finalize */
#endif
};
static
PyObject
*
async_gen_athrow_new
(
Py
AsyncGenObject
*
gen
,
PyObject
*
args
)
__Pyx_async_gen_athrow_new
(
__pyx_
AsyncGenObject
*
gen
,
PyObject
*
args
)
{
PyAsyncGenAThrow
*
o
;
o
=
PyObject_New
(
PyAsyncGenAThrow
,
&
_PyAsyncGenAThrow_
Type
);
__pyx_
PyAsyncGenAThrow
*
o
;
o
=
PyObject_New
(
__pyx_PyAsyncGenAThrow
,
__pyx__PyAsyncGenAThrow
Type
);
if
(
o
==
NULL
)
{
return
NULL
;
}
...
...
@@ -781,3 +930,29 @@ async_gen_athrow_new(PyAsyncGenObject *gen, PyObject *args)
Py_XINCREF
(
args
);
return
(
PyObject
*
)
o
;
}
/* ---------- global type sharing ------------ */
static
int
__pyx_AsyncGen_init
(
void
)
{
// on Windows, C-API functions can't be used in slots statically
__pyx_AsyncGenType_type
.
tp_getattro
=
PyObject_GenericGetAttr
;
__pyx_AsyncGenType
=
__Pyx_FetchCommonType
(
&
__pyx_AsyncGenType_type
);
if
(
unlikely
(
!
__pyx_AsyncGenType
))
return
-
1
;
__pyx__PyAsyncGenAThrowType
=
__Pyx_FetchCommonType
(
&
__pyx__PyAsyncGenAThrowType_type
);
if
(
unlikely
(
!
__pyx__PyAsyncGenAThrowType
))
return
-
1
;
__pyx__PyAsyncGenWrappedValueType
=
__Pyx_FetchCommonType
(
&
__pyx__PyAsyncGenWrappedValueType_type
);
if
(
unlikely
(
!
__pyx__PyAsyncGenWrappedValueType
))
return
-
1
;
__pyx__PyAsyncGenASendType
=
__Pyx_FetchCommonType
(
&
__pyx__PyAsyncGenASendType_type
);
if
(
unlikely
(
!
__pyx__PyAsyncGenASendType
))
return
-
1
;
return
0
;
}
Cython/Utility/Coroutine.c
View file @
76be61a6
...
...
@@ -386,6 +386,11 @@ static PyObject *__Pyx_Generator_Next(PyObject *self);
static
int
__pyx_Generator_init
(
void
);
/*proto*/
//////////////////// AsyncGen ////////////////////
//@requires: AsyncGen.c::AsyncGenerator
// -> empty, only delegates to separate file
//////////////////// CoroutineBase ////////////////////
//@substitute: naming
//@requires: Exceptions.c::PyErrFetchRestore
...
...
@@ -523,8 +528,20 @@ void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
static
CYTHON_INLINE
int
__Pyx_Coroutine_CheckRunning
(
__pyx_CoroutineObject
*
gen
)
{
if
(
unlikely
(
gen
->
is_running
))
{
PyErr_SetString
(
PyExc_ValueError
,
"generator already executing"
);
const
char
*
msg
;
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"coroutine already executing"
;
#endif
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"async generator already executing"
;
#endif
}
else
{
msg
=
"generator already executing"
;
}
PyErr_SetString
(
PyExc_ValueError
,
msg
);
return
1
;
}
return
0
;
...
...
@@ -539,14 +556,30 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
if
(
unlikely
(
self
->
resume_label
==
0
))
{
if
(
unlikely
(
value
&&
value
!=
Py_None
))
{
PyErr_SetString
(
PyExc_TypeError
,
"can't send non-None value to a "
"just-started generator"
);
const
char
*
msg
;
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
self
))
{
msg
=
"can't send non-None value to a just-started coroutine"
;
#endif
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
self
))
{
msg
=
"can't send non-None value to a just-started async generator"
;
#endif
}
else
{
msg
=
"can't send non-None value to a just-started generator"
;
}
PyErr_SetString
(
PyExc_TypeError
,
msg
);
return
NULL
;
}
}
if
(
unlikely
(
self
->
resume_label
==
-
1
))
{
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
self
))
PyErr_SetNone
(
__Pyx_PyExc_StopAsyncIteration
);
else
#endif
PyErr_SetNone
(
PyExc_StopIteration
);
return
NULL
;
}
...
...
@@ -746,9 +779,21 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
PyErr_SetNone
(
PyExc_GeneratorExit
);
retval
=
__Pyx_Coroutine_SendEx
(
gen
,
NULL
);
if
(
retval
)
{
const
char
*
msg
;
Py_DECREF
(
retval
);
PyErr_SetString
(
PyExc_RuntimeError
,
"generator ignored GeneratorExit"
);
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
(
self
))
{
msg
=
"coroutine ignored GeneratorExit"
;
#endif
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
(
self
))
{
msg
=
"async generator ignored GeneratorExit"
;
#endif
}
else
{
msg
=
"generator ignored GeneratorExit"
;
}
PyErr_SetString
(
PyExc_RuntimeError
,
msg
);
return
NULL
;
}
raised_exception
=
PyErr_Occurred
();
...
...
@@ -766,16 +811,11 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
return
NULL
;
}
static
PyObject
*
__Pyx_Coroutine_Throw
(
PyObject
*
self
,
PyObject
*
args
)
{
static
PyObject
*
__Pyx__Coroutine_Throw
(
PyObject
*
self
,
PyObject
*
typ
,
PyObject
*
val
,
PyObject
*
tb
,
PyObject
*
args
,
int
close_on_genexit
)
{
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
typ
;
PyObject
*
tb
=
NULL
;
PyObject
*
val
=
NULL
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
!
PyArg_UnpackTuple
(
args
,
(
char
*
)
"throw"
,
1
,
3
,
&
typ
,
&
val
,
&
tb
))
return
NULL
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)))
return
NULL
;
...
...
@@ -791,17 +831,19 @@ static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
goto
throw_here
;
}
gen
->
is_running
=
1
;
if
(
0
#ifdef __Pyx_Generator_USED
if
(
__Pyx_Generator_CheckExact
(
yf
))
{
ret
=
__Pyx_Coroutine_Throw
(
yf
,
args
);
}
else
||
__Pyx_Generator_CheckExact
(
yf
)
#endif
#ifdef __Pyx_Coroutine_USED
if
(
__Pyx_Coroutine_CheckExact
(
yf
))
{
ret
=
__Pyx_Coroutine_Throw
(
yf
,
args
);
}
else
||
__Pyx_Coroutine_CheckExact
(
yf
)
#endif
{
#ifdef __Pyx_AsyncGen_USED
||
__Pyx_AsyncGen_CheckExact
(
yf
)
#endif
)
{
ret
=
__Pyx__Coroutine_Throw
(
yf
,
typ
,
val
,
tb
,
args
,
close_on_genexit
);
}
else
{
PyObject
*
meth
=
__Pyx_PyObject_GetAttrStr
(
yf
,
PYIDENT
(
"throw"
));
if
(
unlikely
(
!
meth
))
{
Py_DECREF
(
yf
);
...
...
@@ -829,9 +871,18 @@ throw_here:
return
__Pyx_Coroutine_MethodReturn
(
__Pyx_Coroutine_SendEx
(
gen
,
NULL
));
}
static
int
__Pyx_Coroutine_traverse
(
PyObject
*
self
,
visitproc
visit
,
void
*
arg
)
{
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
static
PyObject
*
__Pyx_Coroutine_Throw
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
typ
;
PyObject
*
val
=
NULL
;
PyObject
*
tb
=
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
(
char
*
)
"throw"
,
1
,
3
,
&
typ
,
&
val
,
&
tb
))
return
NULL
;
return
__Pyx__Coroutine_Throw
(
self
,
typ
,
val
,
tb
,
args
,
1
);
}
static
int
__Pyx_Coroutine_traverse
(
__pyx_CoroutineObject
*
gen
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
gen
->
closure
);
Py_VISIT
(
gen
->
classobj
);
Py_VISIT
(
gen
->
yieldfrom
);
...
...
@@ -850,6 +901,11 @@ static int __Pyx_Coroutine_clear(PyObject *self) {
Py_CLEAR
(
gen
->
exc_type
);
Py_CLEAR
(
gen
->
exc_value
);
Py_CLEAR
(
gen
->
exc_traceback
);
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
(
self
))
{
Py_CLEAR
(((
__pyx_AsyncGenObject
*
)
gen
)
->
ag_finalizer
);
}
#endif
Py_CLEAR
(
gen
->
gi_name
);
Py_CLEAR
(
gen
->
gi_qualname
);
return
0
;
...
...
@@ -1238,6 +1294,26 @@ static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
Py_XDECREF
(
msg
);}
#endif
PyObject_GC_Track
(
self
);
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
(
self
))
{
__pyx_AsyncGenObject
*
agen
=
(
__pyx_AsyncGenObject
*
)
self
;
PyObject
*
finalizer
=
agen
->
ag_finalizer
;
if
(
finalizer
&&
!
agen
->
ag_closed
)
{
/* Save the current exception, if any. */
PyObject
*
error_type
,
*
error_value
,
*
error_traceback
,
*
res
;
PyErr_Fetch
(
&
error_type
,
&
error_value
,
&
error_traceback
);
res
=
__Pyx_PyObject_CallOneArg
(
finalizer
,
self
);
if
(
res
==
NULL
)
{
PyErr_WriteUnraisable
(
self
);
}
else
{
Py_DECREF
(
res
);
}
/* Restore the saved exception. */
PyErr_Restore
(
error_type
,
error_value
,
error_traceback
);
return
;
}
#endif
}
__Pyx_Coroutine_dealloc
(
self
);
...
...
@@ -1323,7 +1399,7 @@ static PyTypeObject __pyx_CoroutineType_type = {
0
,
/*tp_doc*/
(
traverseproc
)
__Pyx_Coroutine_traverse
,
/*tp_traverse*/
0
,
/*tp_clear*/
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
#if CYTHON_
USE_ASYNC_SLOTS && CYTHON_
COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
// in order to (mis-)use tp_reserved above, we must also implement tp_richcompare
__Pyx_Coroutine_compare
,
/*tp_richcompare*/
#else
...
...
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