[Python-Dev] why doesn't print pass unicode strings on to the file object?

Guido van Rossum guido@python.org
Tue, 18 Sep 2001 09:17:07 -0400


> > And then, what's the point of handling Unicode if we only accept
> > Unicode-encoded ASCII strings?
> 
> By accepting Unicode, I would specifically require that they, at
> least:
> - do not crash the interpreter when being passed Unicode objects
> - attempt to perform some conversion if they do not support Unicode
>   directly; if they don't know any specific conversion, the default
>   conversion should be used (i.e. that they don't give a TypeError).
> 
> With these assumptions, it is possible to allow print to pass Unicode
> objects to the file's write method, instead of converting Unicode
> itself. This, in turn, enables users to replace sys.stdout with
> something that supports a different encoding.
> 
> Of course, you still may get Unicode errors, since some streams may
> not support all Unicode characters (e.g. since the terminal does not
> support them).

OK.  That's very reasonable.

What do we need to change to make this happen?

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