Add test to verify that nested functions with free variables don't

cause the free variables to leak.
This commit is contained in:
Jeremy Hylton 2001-03-13 02:01:12 +00:00
parent 30c9f3991c
commit 5b44a67bdb
2 changed files with 24 additions and 0 deletions

View File

@ -14,3 +14,4 @@ test_scope
13. UnboundLocal
14. complex definitions
15. scope of global statements
16. check leaks

View File

@ -383,3 +383,26 @@ def f():
return g()
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)