[issue6108] unicode(exception) and str(exception) should return the same message on Py2.6

Nick Coghlan report at bugs.python.org
Sun Dec 13 05:49:14 CET 2009


Nick Coghlan <ncoghlan at gmail.com> added the comment:

I agree the 2.6 implementation creates backwards compatibility problems
with subclasses that only override __str__ that we didn't recognise at
the time.

An alternative approach that should work even for the KeyError case is
for BaseException_unicode to check explicitly for the situation where
the __str__ slot has been overridden but __unicode__ is still the
BaseException version and invoke "PyObject_Unicode(PyObject_Str(self))"
when it detects that situation.

That way subclasses that only override __str__ would continue to see the
old behaviour, while subclasses that don't override either would
continue to benefit from the new behaviour.

----------

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


More information about the Python-bugs-list mailing list