Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-135552: Clear weakrefs to types in GC after garbage finalization not before#135728
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f14f0ba61fc657d8124a9bb215100e649abff79617ac394bc3b18738de8841cf8745e0f1669333fe0f15File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1125,6 +1125,30 @@ def test_something(self): | ||
| """) | ||
| assert_python_ok("-c", source) | ||
| def test_do_not_cleanup_type_subclasses_before_finalization(self): | ||
| # https://github.com/python/cpython/issues/135552 | ||
| 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", textwrap.dedent(code)) | ||
| code_inside_function = textwrap.dedent(F""" | ||
| def test(): | ||
| {textwrap.indent(code, ' ')} | ||
| test() | ||
| """) | ||
| assert_python_ok("-c", code_inside_function) | ||
| class IncrementalGCTests(unittest.TestCase): | ||
| @unittest.skipIf(_testinternalcapi is None, "requires _testinternalcapi") | ||
| @@ -1518,6 +1542,7 @@ def test_ast_fini(self): | ||
| assert_python_ok("-c", code) | ||
sergey-miryanov marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| def setUpModule(): | ||
| global enabled, debug | ||
| enabled = gc.isenabled() | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||
| Split the handling of weak references in the GC if both types and instances | ||||||
| within a generation are unreachable. This prevent the clearing of the | ||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested change
| ||||||
| type's subclasses list too early. This fix a crash that occurs when | ||||||
| :meth:`~object.__del__` modifies the base's attributes and tries to access them from self. | ||||||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.