summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dict.py
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 /Lib/test/test_dict.py
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 'Lib/test/test_dict.py')
-rw-r--r--Lib/test/test_dict.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 403d5eb..2e74b68 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -2,6 +2,7 @@ import unittest
from test import support
import sys, collections, random, string
+import gc, weakref
class DictTest(unittest.TestCase):
@@ -648,6 +649,21 @@ class DictTest(unittest.TestCase):
pass
d = {}
+ def test_container_iterator(self):
+ # Bug #3680: tp_traverse was not implemented for dictiter and
+ # dictview objects.
+ class C(object):
+ pass
+ views = (dict.items, dict.values, dict.keys)
+ for v in views:
+ obj = C()
+ ref = weakref.ref(obj)
+ container = {obj: 1}
+ obj.v = v(container)
+ obj.x = iter(obj.v)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
from test import mapping_tests