Skip to content

Commit ce0a2a8

Browse files
Make repr of C accelerated TaskWakeupMethWrapper the same as of pure Python version (GH-17484)
(cherry picked from commit 969ae7a) Co-authored-by: Andrew Svetlov <[email protected]>
1 parent 7fde4f4 commit ce0a2a8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make repr of C accelerated TaskWakeupMethWrapper the same as of pure Python
2+
version.

Modules/_asynciomodule.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,21 @@ TaskWakeupMethWrapper_dealloc(TaskWakeupMethWrapper *o)
18111811
Py_TYPE(o)->tp_free(o);
18121812
}
18131813

1814+
static PyObject *
1815+
TaskWakeupMethWrapper_get___self__(TaskWakeupMethWrapper *o, void *Py_UNUSED(ignored))
1816+
{
1817+
if (o->ww_task) {
1818+
Py_INCREF(o->ww_task);
1819+
return (PyObject*)o->ww_task;
1820+
}
1821+
Py_RETURN_NONE;
1822+
}
1823+
1824+
static PyGetSetDef TaskWakeupMethWrapper_getsetlist[] = {
1825+
{"__self__", (getter)TaskWakeupMethWrapper_get___self__, NULL, NULL},
1826+
{NULL} /* Sentinel */
1827+
};
1828+
18141829
static PyTypeObject TaskWakeupMethWrapper_Type = {
18151830
PyVarObject_HEAD_INIT(NULL, 0)
18161831
"TaskWakeupMethWrapper",
@@ -1822,6 +1837,7 @@ static PyTypeObject TaskWakeupMethWrapper_Type = {
18221837
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
18231838
.tp_traverse = (traverseproc)TaskWakeupMethWrapper_traverse,
18241839
.tp_clear = (inquiry)TaskWakeupMethWrapper_clear,
1840+
.tp_getset = TaskWakeupMethWrapper_getsetlist,
18251841
};
18261842

18271843
static PyObject *
@@ -3258,7 +3274,7 @@ module_init(void)
32583274
}
32593275
if (module_initialized != 0) {
32603276
return 0;
3261-
}
3277+
}
32623278
else {
32633279
module_initialized = 1;
32643280
}

0 commit comments

Comments
 (0)