Author martin.panter
Recipients Arfrever, The Compiler, martin.panter, r.david.murray, vstinner
Date 2014-12-20.04:18:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1419049118.12.0.397772596768.issue22836@psf.upfronthosting.co.za>
In-reply-to
Content
Here is a patch that substitutes an explanation if the repr() fails. Output now looks like this, terminated with a newline:

=== BrokenObj ===
Exception ignored in: <repr() failed>
Traceback (most recent call last):
  File "<stdin>", line 3, in __del__
Exception: in del
$ ./python -c 'import sys; sys.stdout.detach()'
Exception ignored in: <repr() failed>
ValueError: underlying buffer has been detached

I also made it work sensibly if printing the exception message fails:

>>> class Exception(Exception):
...     def __str__(self): raise Exception("Exception is broken")
... 
>>> f = BrokenObj(); del f
Exception ignored in: <repr() failed>
Traceback (most recent call last):
  File "<stdin>", line 3, in __del__
__main__.Exception: <str() failed>
>>> raise Exception()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
__main__.Exception: <str() failed>
>>>
History
Date User Action Args
2014-12-20 04:18:38martin.pantersetrecipients: + martin.panter, vstinner, Arfrever, r.david.murray, The Compiler
2014-12-20 04:18:38martin.pantersetmessageid: <1419049118.12.0.397772596768.issue22836@psf.upfronthosting.co.za>
2014-12-20 04:18:38martin.panterlinkissue22836 messages
2014-12-20 04:18:37martin.pantercreate