mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Add a testcase to ensure that cycles going through the __class__ link
of a new-style instance are detected by the garbage collector.
This commit is contained in:
parent
c5fe5eb8d2
commit
05e01ee114
1 changed files with 6 additions and 0 deletions
|
@ -83,6 +83,12 @@ def test_newinstance():
|
||||||
gc.collect()
|
gc.collect()
|
||||||
del a
|
del a
|
||||||
expect_nonzero(gc.collect(), "newinstance(2)")
|
expect_nonzero(gc.collect(), "newinstance(2)")
|
||||||
|
del B, C
|
||||||
|
expect_nonzero(gc.collect(), "newinstance(3)")
|
||||||
|
A.a = A()
|
||||||
|
del A
|
||||||
|
expect_nonzero(gc.collect(), "newinstance(4)")
|
||||||
|
expect(gc.collect(), 0, "newinstance(5)")
|
||||||
|
|
||||||
def test_method():
|
def test_method():
|
||||||
# Tricky: self.__init__ is a bound method, it references the instance.
|
# Tricky: self.__init__ is a bound method, it references the instance.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue