Skip to content

Commit 969ae7a

Browse files
authored
Make repr of C accelerated TaskWakeupMethWrapper the same as of pure Python version (GH-17484)
1 parent 7ddcd0c commit 969ae7a

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
@@ -1815,6 +1815,21 @@ TaskWakeupMethWrapper_dealloc(TaskWakeupMethWrapper *o)
18151815
Py_TYPE(o)->tp_free(o);
18161816
}
18171817

1818+
static PyObject *
1819+
TaskWakeupMethWrapper_get___self__(TaskWakeupMethWrapper *o, void *Py_UNUSED(ignored))
1820+
{
1821+
if (o->ww_task) {
1822+
Py_INCREF(o->ww_task);
1823+
return (PyObject*)o->ww_task;
1824+
}
1825+
Py_RETURN_NONE;
1826+
}
1827+
1828+
static PyGetSetDef TaskWakeupMethWrapper_getsetlist[] = {
1829+
{"__self__", (getter)TaskWakeupMethWrapper_get___self__, NULL, NULL},
1830+
{NULL} /* Sentinel */
1831+
};
1832+
18181833
static PyTypeObject TaskWakeupMethWrapper_Type = {
18191834
PyVarObject_HEAD_INIT(NULL, 0)
18201835
"TaskWakeupMethWrapper",
@@ -1826,6 +1841,7 @@ static PyTypeObject TaskWakeupMethWrapper_Type = {
18261841
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
18271842
.tp_traverse = (traverseproc)TaskWakeupMethWrapper_traverse,
18281843
.tp_clear = (inquiry)TaskWakeupMethWrapper_clear,
1844+
.tp_getset = TaskWakeupMethWrapper_getsetlist,
18291845
};
18301846

18311847
static PyObject *
@@ -3266,7 +3282,7 @@ module_init(void)
32663282
}
32673283
if (module_initialized != 0) {
32683284
return 0;
3269-
}
3285+
}
32703286
else {
32713287
module_initialized = 1;
32723288
}

0 commit comments

Comments
 (0)