[Python-Dev] unicode inconsistency?

Neil Schemenauer nas at arctrix.com
Thu Sep 9 21:57:32 CEST 2004

On Thu, Sep 09, 2004 at 03:11:51PM -0400, Tim Peters wrote:
> '%s' is documented as "String (converts any python object using
> str())".  It's str(A()) that raises the exception you're seeing,
> not interpolation.

Shouldn't '%s' % u'\u1234' also raise an exception then?

> To worm around that, you'll effectively have to duplicate
> PyObject_Str's implementation

Yes.  I want something like "PyObject_UnicodeOrStr" that would
return either a unicode object or a str object.  That would make it
easier to write code that produces 'str' results if unicode
characters don't appear in any of the inputs.  Having __str__
methods that can return either 'unicode' or 'str' objects is also
very handy (I don't see how you can say that it doesn't make any

Perhaps I am on the wrong track.  However, if I understand the /F
bot correctly, he favours a design that does not force everthing to
unicode strings.


More information about the Python-Dev mailing list