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 1cd3d85

Browse filesBrowse files
authored
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.
1 parent 10a5c80 commit 1cd3d85
Copy full SHA for 1cd3d85

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.