[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__
Martin Panter
report at bugs.python.org
Sat Dec 20 05:18:38 CET 2014
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 <report at bugs.python.org>
<http://bugs.python.org/issue22836>
_______________________________________
More information about the Python-bugs-list
mailing list