Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-104787: use managed dict in _asyncio #104795

Merged
merged 1 commit into from
May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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},
};

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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},
};

Expand Down Expand Up @@ -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,
};

Expand Down