mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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:
parent
588ff93f13
commit
632fad3933
3 changed files with 24 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue