Visitar URL original
gh-135552: Add tests that check if weakref for tp_subclasses cleared after finalization by sergey-miryanov · Pull Request #136304 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify tests
  • Loading branch information
sergey-miryanov committed Jul 4, 2025
commit b6825da9df07a27a19a8ef36a870c8f0b46d5f29
19 changes: 6 additions & 13 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,30 +1127,23 @@ def test_something(self):

def test_do_not_cleanup_type_subclasses_before_finalization(self):
# https://github.com/python/cpython/issues/135552
Comment thread
sergey-miryanov marked this conversation as resolved.
Outdated
code = textwrap.dedent("""
code = """
class BaseNode:
def __del__(self):
BaseNode.next = BaseNode.next.next
BaseNode.next.next

class Node(BaseNode):
pass

BaseNode.next = Node()
BaseNode.next.next = Node()
""")
assert_python_ok("-c", code)
"""
assert_python_ok("-c", textwrap.dedent(code))

code_inside_function = textwrap.dedent("""
code_inside_function = textwrap.dedent(F"""
def test():
class BaseNode:
def __del__(self):
BaseNode.next = BaseNode.next.next

class Node(BaseNode):
pass

BaseNode.next = Node()
BaseNode.next.next = Node()
{textwrap.indent(code, ' ')}

test()
""")
Expand Down