GH-104787: use managed dict in `_asyncio` (#104795)

This commit is contained in:
Kumar Aditya 2023-05-26 10:30:27 +05:30 committed by GitHub
parent 10c45838e1
commit 72c3d2e105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 9 deletions

View File

@ -122,7 +122,6 @@ typedef enum {
fut_state prefix##_state; \
int prefix##_log_tb; \
int prefix##_blocking; \
PyObject *dict; \
PyObject *prefix##_weakreflist; \
PyObject *prefix##_cancelled_exc;
@ -489,7 +488,6 @@ future_init(FutureObj *fut, PyObject *loop)
PyObject *res;
int is_true;
// Same to FutureObj_clear() but not clearing fut->dict
Py_CLEAR(fut->fut_loop);
Py_CLEAR(fut->fut_callback0);
Py_CLEAR(fut->fut_context0);
@ -814,7 +812,7 @@ FutureObj_clear(FutureObj *fut)
Py_CLEAR(fut->fut_source_tb);
Py_CLEAR(fut->fut_cancel_msg);
Py_CLEAR(fut->fut_cancelled_exc);
Py_CLEAR(fut->dict);
_PyObject_ClearManagedDict((PyObject *)fut);
return 0;
}
@ -832,7 +830,7 @@ FutureObj_traverse(FutureObj *fut, visitproc visit, void *arg)
Py_VISIT(fut->fut_source_tb);
Py_VISIT(fut->fut_cancel_msg);
Py_VISIT(fut->fut_cancelled_exc);
Py_VISIT(fut->dict);
_PyObject_VisitManagedDict((PyObject *)fut, visit, arg);
return 0;
}
@ -1502,7 +1500,6 @@ static PyMethodDef FutureType_methods[] = {
static PyMemberDef FutureType_members[] = {
{"__weaklistoffset__", T_PYSSIZET, offsetof(FutureObj, fut_weakreflist), READONLY},
{"__dictoffset__", T_PYSSIZET, offsetof(FutureObj, dict), READONLY},
{NULL},
};
@ -1551,7 +1548,7 @@ static PyType_Spec Future_spec = {
.name = "_asyncio.Future",
.basicsize = sizeof(FutureObj),
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_IMMUTABLETYPE),
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_MANAGED_DICT),
.slots = Future_slots,
};
@ -2183,7 +2180,7 @@ TaskObj_traverse(TaskObj *task, visitproc visit, void *arg)
Py_VISIT(fut->fut_source_tb);
Py_VISIT(fut->fut_cancel_msg);
Py_VISIT(fut->fut_cancelled_exc);
Py_VISIT(fut->dict);
_PyObject_VisitManagedDict((PyObject *)fut, visit, arg);
return 0;
}
@ -2640,7 +2637,6 @@ static PyMethodDef TaskType_methods[] = {
static PyMemberDef TaskType_members[] = {
{"__weaklistoffset__", T_PYSSIZET, offsetof(TaskObj, task_weakreflist), READONLY},
{"__dictoffset__", T_PYSSIZET, offsetof(TaskObj, dict), READONLY},
{NULL},
};
@ -2677,7 +2673,7 @@ static PyType_Spec Task_spec = {
.name = "_asyncio.Task",
.basicsize = sizeof(TaskObj),
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_IMMUTABLETYPE),
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_MANAGED_DICT),
.slots = Task_slots,
};