8000 gh-135552: Add tests that check if weakref for tp_subclasses cleared after finalization by sergey-miryanov · Pull Request #136304 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-135552: Add tests that check if weakref for tp_subclasses cleared after finalization #136304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
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
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
0