This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iritkatriel
Recipients amaury.forgeotdarc, dizzy, gregory.p.smith, iritkatriel
Date 2021-02-12.23:57:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1613174276.74.0.178008811754.issue10794@roundup.psfhosted.org>
In-reply-to
Content
I think this issue is out of date.

For Mihai's example I get:

>>> class A(object):
...   def __init__(self):
...     raise Exception('init error')
...     self.m = 'Hello world'
...   def __del__(self):
...     #raise RuntimeError('my runtime error')
...     self.__del__()
...
>>> def func():
...   h = A()
...
>>> func()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in func
  File "<stdin>", line 3, in __init__
Exception: init error
>>>



For Amaury's first example I get what I expect:


>>> class A:
...     def close(self):
...         self.close()
...     def __del__(self):
...         self.close()
...
>>> class A:
...     def close(self):
...         self.close()
...     def __del__(self):
...         self.close()
...
>>> def func():
...   h = A()
...
>>> func()
Exception ignored in: <function A.__del__ at 0x000002921A8E1820>
Traceback (most recent call last):
  File "<stdin>", line 5, in __del__
  File "<stdin>", line 3, in close
  File "<stdin>", line 3, in close
  File "<stdin>", line 3, in close
  [Previous line repeated 994 more times]
RecursionError: maximum recursion depth exceeded
>>>


And for Amaury's trashcan example (even when I increase the list length to well over the trashcan threshold): 

>>> class C:
...     def __del__(self):
...         print('.')
...         x = self
...         for i in range(49):    # PyTrash_UNWIND_LEVEL-1
...             x = [x]
...
>>> l = [C()]
>>> del l
.
>>> class C:
...      def __del__(self):
...          print('.')
...          x = self
...          for i in range(5000):
...             x = [x]
...
>>> l = [C()]
>>> del l
.
>>>
History
Date User Action Args
2021-02-12 23:57:56iritkatrielsetrecipients: + iritkatriel, gregory.p.smith, amaury.forgeotdarc, dizzy
2021-02-12 23:57:56iritkatrielsetmessageid: <1613174276.74.0.178008811754.issue10794@roundup.psfhosted.org>
2021-02-12 23:57:56iritkatriellinkissue10794 messages
2021-02-12 23:57:55iritkatrielcreate