diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-01 14:11:22 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-01 14:11:22 (GMT) |
commit | aa687902f21dc32a72f578a992cc9e44444ced44 (patch) | |
tree | dcd5060070b8236e3f8a3c8561030099d95992f7 /Lib/test/test_set.py | |
parent | 4ba9f412bfec4462e17c91e6fe63aeda80b43974 (diff) | |
download | cpython-aa687902f21dc32a72f578a992cc9e44444ced44.zip cpython-aa687902f21dc32a72f578a992cc9e44444ced44.tar.gz cpython-aa687902f21dc32a72f578a992cc9e44444ced44.tar.bz2 |
Issue #3680: Reference cycles created through a dict, set or deque iterator did not get collected.
Diffstat (limited to 'Lib/test/test_set.py')
-rw-r--r-- | Lib/test/test_set.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index d38a675..8d05712 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -1,6 +1,7 @@ import unittest from test import test_support -from weakref import proxy +import gc +import weakref import operator import copy import pickle @@ -322,6 +323,18 @@ class TestJointOps(unittest.TestCase): self.assertEqual(sum(elem.hash_count for elem in d), n) self.assertEqual(d3, dict.fromkeys(d, 123)) + def test_container_iterator(self): + # Bug # XXX: tp_traverse was not implemented for set iterator object + class C(object): + pass + obj = C() + ref = weakref.ref(obj) + container = set([obj, 1]) + obj.x = iter(container) + del obj, container + gc.collect() + self.assert_(ref() is None, "Cycle was not collected") + class TestSet(TestJointOps): thetype = set @@ -538,7 +551,7 @@ class TestSet(TestJointOps): def test_weakref(self): s = self.thetype('gallahad') - p = proxy(s) + p = weakref.proxy(s) self.assertEqual(str(p), str(s)) s = None self.assertRaises(ReferenceError, str, p) |