Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer

is still present in the containing structure.
This commit is contained in:
Amaury Forgeot d'Arc 2008-02-16 20:55:24 +00:00
parent 588ff93f13
commit 632fad3933
3 changed files with 24 additions and 1 deletions

View file

@ -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)