Martin Panter added the comment:

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>
>>>

----------
keywords: +patch
Added file: http://bugs.python.org/file37511/unraisable-continue.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22836>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to