diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-02-16 20:55:24 +0000 |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-02-16 20:55:24 +0000 |
commit | 632fad393304db484f508d1833a9fda52b7f193a (patch) | |
tree | 47332f046dac89a7d67b08d414154015233eeb38 /Lib/test/test_scope.py | |
parent | 588ff93f1383436694e26c962528291913012296 (diff) | |
download | cpython-git-632fad393304db484f508d1833a9fda52b7f193a.tar.gz |
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
Diffstat (limited to 'Lib/test/test_scope.py')
-rw-r--r-- | Lib/test/test_scope.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index db88dbd513..cd2d98c075 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -597,6 +597,24 @@ self.assert_(X.passed) f(4)() + def testFreeingCell(self): + # Test what happens when a finalizer accesses + # the cell where the object was stored. + class Special: + def __del__(self): + nestedcell_get() + + def f(): + global nestedcell_get + def nestedcell_get(): + return c + + c = (Special(),) + c = 2 + + f() # used to crash the interpreter... + + def test_main(): run_unittest(ScopeTests) |