[New-bugs-announce] [issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

Florian Bruhin report at bugs.python.org
Mon Nov 10 11:22:49 CET 2014


New submission from Florian Bruhin:

When there's an unraisable exception (e.g. in __del__), and there's an exception in __repr__ as well, PyErr_WriteUnraisable returns after writing "Exception ignored in:" immediately.

I'd expect it to fall back to the default __repr__ instead.

See the attached example script.

Output with 3.4:

=== Obj ===
Exception ignored in: <bound method Obj.__del__ of <__main__.Obj object at 0x7fd842deb4a8>>
Traceback (most recent call last):
  File "test.py", line 4, in __del__
    raise Exception('in del')
Exception: in del
=== BrokenObj ===
Exception ignored in: (no newline)

Output with 2.7:

=== Obj ===
Exception Exception: Exception('in del',) in <bound method Obj.__del__ of <__main__.Obj object at 0x7fa824dbfa50>> ignored
=== BrokenObj ===
Exception Exception: Exception('in del',) in  ignored

The output with 2.7 is a bit more useful, but still confusing.

----------
components: Interpreter Core
files: repr_exception.py
messages: 230950
nosy: The Compiler
priority: normal
severity: normal
status: open
title: Broken "Exception ignored in:" message on exceptions in __repr__
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file37166/repr_exception.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22836>
_______________________________________


More information about the New-bugs-announce mailing list