File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1127,18 +1127,24 @@ def test_something(self):
11271127
11281128 def test_do_not_cleanup_type_subclasses_before_finalization (self ):
11291129 # https://github.com/python/cpython/issues/135552
1130+ # If we cleanup weakrefs for tp_subclasses before calling
1131+ # the finalizer (__del__) then the line `fail = BaseNode.next.next`
1132+ # should fail because we are trying to access a subclass
1133+ # atribute. But subclass type cache was not properly invalidated.
11301134 code = """
11311135 class BaseNode:
11321136 def __del__(self):
11331137 BaseNode.next = BaseNode.next.next
1134- BaseNode.next.next
1138+ fail = BaseNode.next.next
11351139
11361140 class Node(BaseNode):
11371141 pass
11381142
11391143 BaseNode.next = Node()
11401144 BaseNode.next.next = Node()
11411145 """
1146+ # this test checks garbage collection while interp
1147+ # finalization
11421148 assert_python_ok ("-c" , textwrap .dedent (code ))
11431149
11441150 code_inside_function = textwrap .dedent (F"""
@@ -1147,6 +1153,7 @@ def test():
11471153
11481154 test()
11491155 """ )
1156+ # this test checks regular garbage collection
11501157 assert_python_ok ("-c" , code_inside_function )
11511158
11521159
You can’t perform that action at this time.
0 commit comments