summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-01 15:35:33 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-01 15:35:33 (GMT)
commit7ddda7830c362f59f154681fe9b2aa0c161309b1 (patch)
tree6ed81212c2f0a90fabc058a04c516d9139477fa8 /Objects/setobject.c
parent75edad0502c648148c6139b2d81a128559573c0d (diff)
downloadcpython-7ddda7830c362f59f154681fe9b2aa0c161309b1.zip
cpython-7ddda7830c362f59f154681fe9b2aa0c161309b1.tar.gz
cpython-7ddda7830c362f59f154681fe9b2aa0c161309b1.tar.bz2
Merged revisions 68128 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68128 | antoine.pitrou | 2009-01-01 15:11:22 +0100 (jeu., 01 janv. 2009) | 3 lines Issue #3680: Reference cycles created through a dict, set or deque iterator did not get collected. ........
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index eb223a3..d3243dd 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -802,7 +802,14 @@ static void
setiter_dealloc(setiterobject *si)
{
Py_XDECREF(si->si_set);
- PyObject_Del(si);
+ PyObject_GC_Del(si);
+}
+
+static int
+setiter_traverse(setiterobject *si, visitproc visit, void *arg)
+{
+ Py_VISIT(si->si_set);
+ return 0;
}
static PyObject *
@@ -880,9 +887,9 @@ PyTypeObject PySetIter_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)setiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -895,7 +902,7 @@ PyTypeObject PySetIter_Type = {
static PyObject *
set_iter(PySetObject *so)
{
- setiterobject *si = PyObject_New(setiterobject, &PySetIter_Type);
+ setiterobject *si = PyObject_GC_New(setiterobject, &PySetIter_Type);
if (si == NULL)
return NULL;
Py_INCREF(so);
@@ -903,6 +910,7 @@ set_iter(PySetObject *so)
si->si_used = so->used;
si->si_pos = 0;
si->len = so->used;
+ _PyObject_GC_TRACK(si);
return (PyObject *)si;
}