diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-25 18:26:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 18:26:44 (GMT) |
commit | bd404ccac0d3e8358995ac0cbeec9373bb6c4d96 (patch) | |
tree | 4614a5b0198078613a8e84dc79def1454895533b /Modules/arraymodule.c | |
parent | d3c277a59c3d93fb92f7026f63678083d1d49fc5 (diff) | |
download | cpython-bd404ccac0d3e8358995ac0cbeec9373bb6c4d96.zip cpython-bd404ccac0d3e8358995ac0cbeec9373bb6c4d96.tar.gz cpython-bd404ccac0d3e8358995ac0cbeec9373bb6c4d96.tar.bz2 |
bpo-42972: Fully implement GC protocol for arraymodule types (GH-26114)
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r-- | Modules/arraymodule.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index aa5886f..30fb7c9 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -661,10 +661,18 @@ ins1(arrayobject *self, Py_ssize_t where, PyObject *v) /* Methods */ +static int +array_tp_traverse(arrayobject *op, visitproc visit, void *arg) +{ + Py_VISIT(Py_TYPE(op)); + return 0; +} + static void array_dealloc(arrayobject *op) { PyTypeObject *tp = Py_TYPE(op); + PyObject_GC_UnTrack(op); if (op->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) op); @@ -2820,7 +2828,7 @@ static PyType_Slot array_slots[] = { {Py_tp_getset, array_getsets}, {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_new, array_new}, - {Py_tp_free, PyObject_Del}, + {Py_tp_traverse, array_tp_traverse}, /* as sequence */ {Py_sq_length, array_length}, @@ -2848,7 +2856,7 @@ static PyType_Spec array_spec = { .name = "array.array", .basicsize = sizeof(arrayobject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_IMMUTABLETYPE | + Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_SEQUENCE), .slots = array_slots, }; @@ -2922,6 +2930,7 @@ arrayiter_dealloc(arrayiterobject *it) static int arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(it)); Py_VISIT(it->ao); return 0; } |