[Python-checkins] CVS: python/dist/src/Lib/test test_scope.py,1.10,1.11
Jeremy Hylton
jhylton@usw-pr-cvs1.sourceforge.net
Mon, 12 Mar 2001 18:01:14 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30749/Lib/test
Modified Files:
test_scope.py
Log Message:
Add test to verify that nested functions with free variables don't
cause the free variables to leak.
Index: test_scope.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** test_scope.py 2001/03/01 20:35:45 1.10
--- test_scope.py 2001/03/13 02:01:12 1.11
***************
*** 384,385 ****
--- 384,408 ----
verify(f() == 2)
verify(x == 2)
+
+ print "16. check leaks"
+
+ class Foo:
+ count = 0
+
+ def __init__(self):
+ Foo.count += 1
+
+ def __del__(self):
+ Foo.count -= 1
+
+ def f1():
+ x = Foo()
+ def f2():
+ return x
+ f2()
+
+ for i in range(100):
+ f1()
+
+ verify(Foo.count == 0)
+