[issue1583863] __str__ cannot be overridden on unicode-derived classes

STINNER Victor report at bugs.python.org
Mon Mar 30 12:51:56 CEST 2009


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

Case "S" (type str): "%s" uses _PyObject_Str() which checks the object 
type with PyString_CheckExact().

Case "U" (type unicode) "%s" uses PyUnicode_Check() and then calls 
PyUnicode_Format(). PyUnicode_Format() uses PyUnicode_Check() to check 
the object object. It should uses PyUnicode_CheckExact() instead.

xxx_CheckExact() is different than xxx_Check(): exact is only true for 
the base type, whereas the the second is also true for subclass.

----------

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


More information about the Python-bugs-list mailing list