[Python-Dev] More Unicode support

Guido van Rossum guido@python.org
Mon, 06 Nov 2000 12:53:36 -0500

> > Adding unistr() and StreamRecoder isn't enough.  The problem is that
> > when you set sys.stdout to a StreamRecoder, the print statement
> > doesn't do the right thing!  Try it.  print u"foo" will work, but
> > print u"\u1234" will fail because print always applies the default
> > encoding.

> Hmm, that's due to PyFile_WriteObject() calling PyObject_Str().
> Perhaps we ought to let it call PyObject_Unicode() (which you
> find in the patch on SF) instead for Unicode objects. That way
> the file-like .write() method will be given a Unicode object
> and StreamRecoder could then do the trick.

That's still not enough. Classes and types should be able to have a
__str__ (or tp_str) that yields Unicode too.

--Guido van Rossum (home page: http://www.python.org/~guido/)