Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e30fe27

Browse filesBrowse files
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. (cherry picked from commit 1cd3d85) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 2f2ea96 commit e30fe27
Copy full SHA for e30fe27

File tree

Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The _thread.RLock type now fully implement the GC protocol: add a traverse
2+
function and the :const:`Py_TPFLAGS_HAVE_GC` flag. Patch by Victor Stinner.

‎Modules/_threadmodule.c

Copy file name to clipboardExpand all lines: Modules/_threadmodule.c
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ typedef struct {
327327
PyObject *in_weakreflist;
328328
} rlockobject;
329329

330+
static int
331+
rlock_traverse(rlockobject *self, visitproc visit, void *arg)
332+
{
333+
Py_VISIT(Py_TYPE(self));
334+
return 0;
335+
}
336+
337+
330338
static void
331339
rlock_dealloc(rlockobject *self)
332340
{
@@ -579,13 +587,14 @@ static PyType_Slot rlock_type_slots[] = {
579587
{Py_tp_alloc, PyType_GenericAlloc},
580588
{Py_tp_new, rlock_new},
581589
{Py_tp_members, rlock_type_members},
590+
{Py_tp_traverse, rlock_traverse},
582591
{0, 0},
583592
};
584593

585594
static PyType_Spec rlock_type_spec = {
586595
.name = "_thread.RLock",
587596
.basicsize = sizeof(rlockobject),
588-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
597+
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
589598
.slots = rlock_type_slots,
590599
};
591600

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.