Commit 76be61a6 authored by Stefan Behnel's avatar Stefan Behnel

adapt and escape all copied AsyncGen code for Cython

parent 21cd57ac
/* ========= 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
PyAsyncGenObject *aw_gen;
__pyx_AsyncGenObject *aw_gen;
PyObject *aw_sendval;
int aw_state;
} PyAsyncGenASend;
} __pyx_PyAsyncGenASend;
typedef struct {
PyObject_HEAD
PyAsyncGenObject *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__PyAsyncGenWrappedValueType)
#define PyAsyncGenASend_CheckExact(o) \
(Py_TYPE(o) == &_PyAsyncGenASend_Type)
#define __pyx_PyAsyncGenASend_CheckExact(o) \
(Py_TYPE(o) == __pyx__PyAsyncGenASendType)
static int
async_gen_traverse(PyAsyncGenObject *gen, visitproc visit, void *arg)
__Pyx_async_gen_traverse(__pyx_AsyncGenObject *gen, visitproc visit, void *arg)
{
Py_VISIT(gen->ag_finalizer);
return gen_traverse((PyGenObject*)gen, visit, arg);
return __Pyx_Coroutine_traverse((__pyx_CoroutineObject*)gen, visit, arg);
}
static PyObject *
async_gen_repr(PyAsyncGenObject *o)
__Pyx_async_gen_repr(__pyx_CoroutineObject *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(PyAsyncGenObject *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(PyAsyncGenObject *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(PyAsyncGenObject *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(PyAsyncGenObject *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_set_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_get_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_Type = {
PyTypeObject __pyx_AsyncGenType_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"async_generator", /* tp_name */
sizeof(PyAsyncGenObject), /* 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__PyAsyncGenASendType);
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(PyAsyncGenObject *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((PyGenObject*)o->aw_gen, args);
result = async_gen_unwrap_value(o->aw_gen, result);
result = __Pyx_Coroutine_Throw((PyObject*)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_Type = {
PyTypeObject __pyx__PyAsyncGenASendType_type = {
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(PyAsyncGenObject *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__PyAsyncGenASendType);
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_Type = {
PyTypeObject __pyx__PyAsyncGenWrappedValueType_type = {
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__PyAsyncGenWrappedValueType);
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
retval = __Pyx__Coroutine_Throw((PyObject*)gen,
/* Do not close generator when
PyExc_GeneratorExit is passed */
PyExc_GeneratorExit, NULL, NULL);
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
retval = __Pyx__Coroutine_Throw((PyObject*)gen,
/* Do not close generator when
PyExc_GeneratorExit is passed */
typ, val, tb);
retval = async_gen_unwrap_value(o->ac_gen, retval);
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((PyGenObject*)o->ac_gen, args);
retval = __Pyx_Coroutine_Throw((PyObject*)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_Type = {
PyTypeObject __pyx__PyAsyncGenAThrowType_type = {
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(PyAsyncGenObject *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__PyAsyncGenAThrowType);
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;
}
......@@ -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
......
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