summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2023-05-26 05:00:27 (GMT)
committerGitHub <noreply@github.com>2023-05-26 05:00:27 (GMT)
commit72c3d2e105f120f6f2bce410699b34dac4e948fd (patch)
treed9ca23cf805693b48e590a31556da8bea529c772
parent10c45838e1de47ef57708c71e3d9c2ddb78d493d (diff)
downloadcpython-72c3d2e105f120f6f2bce410699b34dac4e948fd.zip
cpython-72c3d2e105f120f6f2bce410699b34dac4e948fd.tar.gz
cpython-72c3d2e105f120f6f2bce410699b34dac4e948fd.tar.bz2
GH-104787: use managed dict in `_asyncio` (#104795)
-rw-r--r--Modules/_asynciomodule.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 7e33558..08ce172 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -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,
};