[Web-SIG] WSGI, Python 3 and Unicode
Phillip J. Eby
pje at telecommunity.com
Fri Dec 7 02:48:55 CET 2007
At 08:08 PM 12/6/2007 -0500, Adam Atlas wrote:
>On 6 Dec 2007, at 18:13, Graham Dumpleton wrote:
> > In Python 3 the default for string type objects will effectively be
> > Unicode. Is WSGI going to be made to somehow cope with that, or will
> > application instead be required to return byte string objects instead?
>I'd say it would be best to only accept `bytes` objects; anything else
>would require some guesswork. Maybe, at most, it could try to encode
>returned Unicode objects as ISO-8859-1, and have it be an error if
>that's not possible.
Actually, I'd prefer to look at it the other way around: a Python 3
WSGI server or middleware *may* accept bytes objects instead of str.
This is relatively easy for the response side of things, but the
request side is rather more difficult, since wsgi.input may need to
be binary rather than text mode. (I think we can reasonably assume
that wsgi.errors is a text mode stream, and should support a
More information about the Web-SIG