Skip to content

Commit 398c4f5

Browse files
Add extra comments
1 parent f62d43e commit 398c4f5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/test/test_gc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)