summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index b8a88e6..b998a04 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -532,9 +532,16 @@ _asyncio_Future_remove_done_callback(FutureObj *self, PyObject *fn)
goto fail;
}
if (ret == 0) {
- Py_INCREF(item);
- PyList_SET_ITEM(newlist, j, item);
- j++;
+ if (j < len) {
+ Py_INCREF(item);
+ PyList_SET_ITEM(newlist, j, item);
+ j++;
+ }
+ else {
+ if (PyList_Append(newlist, item)) {
+ goto fail;
+ }
+ }
}
}