[issue2517] Error when printing an exception containing a Unicode string
Nick Coghlan
report at bugs.python.org
Wed Jun 11 12:02:04 CEST 2008
Nick Coghlan <ncoghlan at gmail.com> added the comment:
Here's the key difference with the way PyObject_Format looks up the
pseudo-slot method:
PyObject *method = _PyType_Lookup(Py_TYPE(obj),
str__format__);
_PyType_Lookup instead of PyObject_GetAttr - so unicode(Exception) would
only look for type.__unicode__ and avoid getting confused by the utterly
irrelevant Exception.__unicode__ method (which is intended only for
printing Exception instances, not for printing the Exception type itself).
You then need the PyInstance_Check/PyObject_GetAttr special case for
retrieving the bound method because _PyType_Lookup won't work on classic
class instances.
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2517>
_______________________________________
More information about the Python-bugs-list
mailing list