Issue 2246: itertools grouper object did not participate in GC (should be backported).

This commit is contained in:
Raymond Hettinger 2008-03-06 22:51:36 +00:00
parent ad47fa141c
commit a1ca94a102
2 changed files with 22 additions and 5 deletions

View file

@ -766,6 +766,13 @@ class TestGC(unittest.TestCase):
a = []
self.makecycle(groupby([a]*2, lambda x:x), a)
def test_issue2246(self):
# Issue 2246 -- the _grouper iterator was not included in GC
n = 10
keyfunc = lambda x: x
for i, j in groupby(xrange(n), key=keyfunc):
keyfunc.__dict__.setdefault('x',[]).append(j)
def test_ifilter(self):
a = []
self.makecycle(ifilter(lambda x:True, [a]*2), a)