summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_b1.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1999-01-28 19:44:06 (GMT)
committerBarry Warsaw <barry@python.org>1999-01-28 19:44:06 (GMT)
commitab11f60bb34f2d04b0f694fd4275a9d954c478cd (patch)
tree4bcb89fe77449a6faf6a4e5f602d7917fe9734ed /Lib/test/test_b1.py
parent30aa1e7d3123d42d2d2c9f20a66c980004834633 (diff)
downloadcpython-ab11f60bb34f2d04b0f694fd4275a9d954c478cd.zip
cpython-ab11f60bb34f2d04b0f694fd4275a9d954c478cd.tar.gz
cpython-ab11f60bb34f2d04b0f694fd4275a9d954c478cd.tar.bz2
Added a new test for old filter() memory leak
Diffstat (limited to 'Lib/test/test_b1.py')
-rw-r--r--Lib/test/test_b1.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py
index 020c8bc..7155294 100644
--- a/Lib/test/test_b1.py
+++ b/Lib/test/test_b1.py
@@ -184,6 +184,23 @@ if filter(None, Squares(10)) != [1, 4, 9, 16, 25, 36, 49, 64, 81]:
raise TestFailed, 'filter(None, Squares(10))'
if filter(lambda x: x%2, Squares(10)) != [1, 9, 25, 49, 81]:
raise TestFailed, 'filter(oddp, Squares(10))'
+class StrSquares:
+ def __init__(self, max):
+ self.max = max
+ self.sofar = []
+ def __len__(self):
+ return len(self.sofar)
+ def __getitem__(self, i):
+ if not 0 <= i < self.max:
+ raise IndexError
+ n = len(self.sofar)
+ while n <= i:
+ self.sofar.append(str(n*n))
+ n = n+1
+ return self.sofar[i]
+def identity(item):
+ return 1
+filter(identity, Squares(5))
print 'float'
if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)'