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 4d7f8f9

Browse filesBrowse files
author
Erlend Egeberg Aasland
authored
bpo-42972: Fully support GC protocol for _queue.SimpleQueue (GH-26372)
1 parent abc4bd5 commit 4d7f8f9
Copy full SHA for 4d7f8f9

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+10
-1
lines changed

‎Modules/_queuemodule.c

Copy file name to clipboardExpand all lines: Modules/_queuemodule.c
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ class _queue.SimpleQueue "simplequeueobject *" "simplequeue_get_state_by_type(ty
3434
[clinic start generated code]*/
3535
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0a4023fe4d198c8d]*/
3636

37+
static int
38+
simplequeue_clear(simplequeueobject *self)
39+
{
40+
Py_CLEAR(self->lst);
41+
return 0;
42+
}
43+
3744
static void
3845
simplequeue_dealloc(simplequeueobject *self)
3946
{
@@ -46,7 +53,7 @@ simplequeue_dealloc(simplequeueobject *self)
4653
PyThread_release_lock(self->lock);
4754
PyThread_free_lock(self->lock);
4855
}
49-
Py_XDECREF(self->lst);
56+
(void)simplequeue_clear(self);
5057
if (self->weakreflist != NULL)
5158
PyObject_ClearWeakRefs((PyObject *) self);
5259
Py_TYPE(self)->tp_free(self);
@@ -57,6 +64,7 @@ static int
5764
simplequeue_traverse(simplequeueobject *self, visitproc visit, void *arg)
5865
{
5966
Py_VISIT(self->lst);
67+
Py_VISIT(Py_TYPE(self));
6068
return 0;
6169
}
6270

@@ -362,6 +370,7 @@ static PyType_Slot simplequeue_slots[] = {
362370
{Py_tp_dealloc, simplequeue_dealloc},
363371
{Py_tp_doc, (void *)simplequeue_new__doc__},
364372
{Py_tp_traverse, simplequeue_traverse},
373+
{Py_tp_clear, simplequeue_clear},
365374
{Py_tp_members, simplequeue_members},
366375
{Py_tp_methods, simplequeue_methods},
367376
{Py_tp_new, simplequeue_new},

0 commit comments

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