Skip to content

"__del__" method sometimes doesn't run in time #131978

@Locked-chess-official

Description

@Locked-chess-official

Bug report

Bug description:

 >>>class A:
 ...   def __del__(self):
 ...       print(f'object {id(self)} is deleted')
 ...        
>>>a = A()
>>>b = A()
>>>b.AA = a
>>>del a
>>>b.AA
<__main__.A object at 0x0000024720B18980>
>>>del b
object 2504514290384 is deleted
>>>c = A()
>>>0x0000024720B18980
object 2504514439552 is deleted
2504514439552
>>>a = A()
>>>b = A()
>>>b.AA = a
>>>del a
>>>1
1
>>>del b
object 2504514803344 is deleted
object 2504514603360 is deleted

In IDLE the "a.del" method began to run until the id of a was reprinted instead of "a" and "b" were deleted in the first condition, but in the second condition it doesn't run in the same way. I think that it should run in the same way because there's no other quote about "a" and "b".

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions