diff options
author | Victor Stinner <vstinner@python.org> | 2021-06-15 13:09:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 13:09:24 (GMT) |
commit | 1cd3d859a49b047dd08abb6f44f0539564d3525a (patch) | |
tree | d3e139bc97bc1f074934c84dfc3a2fc828bf8de4 /Modules/_threadmodule.c | |
parent | 10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f (diff) | |
download | cpython-1cd3d859a49b047dd08abb6f44f0539564d3525a.zip cpython-1cd3d859a49b047dd08abb6f44f0539564d3525a.tar.gz cpython-1cd3d859a49b047dd08abb6f44f0539564d3525a.tar.bz2 |
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r-- | Modules/_threadmodule.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index d4d5c0a..3f7f1d2 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -327,6 +327,14 @@ typedef struct { PyObject *in_weakreflist; } rlockobject; +static int +rlock_traverse(rlockobject *self, visitproc visit, void *arg) +{ + Py_VISIT(Py_TYPE(self)); + return 0; +} + + static void rlock_dealloc(rlockobject *self) { @@ -579,13 +587,14 @@ static PyType_Slot rlock_type_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_new, rlock_new}, {Py_tp_members, rlock_type_members}, + {Py_tp_traverse, rlock_traverse}, {0, 0}, }; static PyType_Spec rlock_type_spec = { .name = "_thread.RLock", .basicsize = sizeof(rlockobject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, .slots = rlock_type_slots, }; |