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 
Traceback (most recent call last):
  File "", 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
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:

Python tracker <>
Python-bugs-list mailing list

Reply via email to