diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-03-13 02:01:12 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-03-13 02:01:12 (GMT) |
commit | 5b44a67bdb67545679a2e1bfcf482996f8d8abb5 (patch) | |
tree | f2d0cb8e83d555ceee866678fd0735c2948dd973 /Lib/test/test_scope.py | |
parent | 30c9f3991cfb6a8179ea5dcf15fe17030dfbad05 (diff) | |
download | cpython-5b44a67bdb67545679a2e1bfcf482996f8d8abb5.zip cpython-5b44a67bdb67545679a2e1bfcf482996f8d8abb5.tar.gz cpython-5b44a67bdb67545679a2e1bfcf482996f8d8abb5.tar.bz2 |
Add test to verify that nested functions with free variables don't
cause the free variables to leak.
Diffstat (limited to 'Lib/test/test_scope.py')
-rw-r--r-- | Lib/test/test_scope.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index 0633b14..4bd8ed7 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -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) + |