[pygobject/benzea/tmp] fixup! fixup! async: Add a new async type that is an awaitable for a _finish call
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/benzea/tmp] fixup! fixup! async: Add a new async type that is an awaitable for a _finish call
- Date: Tue, 28 Dec 2021 23:51:11 +0000 (UTC)
commit ed8b3209fd9c57dafef05c59ca4de81ddc28f081
Author: Benjamin Berg <bberg redhat com>
Date: Wed Dec 29 00:50:20 2021 +0100
fixup! fixup! async: Add a new async type that is an awaitable for a _finish call
gi/pygi-async.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/gi/pygi-async.c b/gi/pygi-async.c
index 2f57ee6e..30f6c2a3 100644
--- a/gi/pygi-async.c
+++ b/gi/pygi-async.c
@@ -339,7 +339,14 @@ async_iternext (PyGIAsync *self) {
PyErr_SetObject(PyExceptionInstance_Class(self->exception), self->exception);
return NULL;
} else {
- PyErr_SetObject(PyExc_StopIteration, self->result);
+ PyObject *e;
+
+ e = PyObject_CallFunctionObjArgs(PyExc_StopIteration, self->result, NULL);
+ if (e == NULL)
+ return NULL;
+
+ PyErr_SetObject(PyExc_StopIteration, e);
+ Py_DECREF(e);
return NULL;
}
}
@@ -415,9 +422,11 @@ finally:
static void
async_dealloc(PyGIAsync *self)
{
+#ifndef PYPY_VERSION
/* The finalizer might resurrect the object */
if (PyObject_CallFinalizerFromDealloc((PyObject *)self) < 0)
return;
+#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -594,7 +603,11 @@ int pygi_async_register_types(PyObject *module) {
PyObject *contextvars = NULL;
#endif
+#ifndef PYPY_VERSION
PyGIAsync_Type.tp_finalize = (destructor)async_finalize;
+#else
+ PyGIAsync_Type.tp_del = (destructor)async_finalize;
+#endif
PyGIAsync_Type.tp_dealloc = (destructor)async_dealloc;
PyGIAsync_Type.tp_repr = (reprfunc)async_repr;
PyGIAsync_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_FINALIZE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]