[Python-Dev] __str__ bug?

Nick Coghlan ncoghlan at gmail.com
Tue Oct 24 12:04:22 CEST 2006


Mike Krell wrote:
> Is this a bug?  If not, how do I override __str__ on a unicode derived class?

Based on the behaviour of str and the fact that overriding unicode.__repr__ 
works just fine, I'd say file a bug on SF.

I think this bit in PyUnicode_Format needs to use PyUnicode_CheckExact instead 
of PyUnicode_Check:

             case 's':
	    case 'r':
		if (PyUnicode_Check(v) && c == 's') {

The corresponding code in PyString_Format makes a call to _PyObject_Str which 
deals with subclasses correctly.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list