[Web-SIG] Python 3.0 and WSGI 1.0.
P.J. Eby
pje at telecommunity.com
Fri May 8 17:58:28 CEST 2009
At 08:07 AM 5/8/2009 -0700, Robert Brewer wrote:
>I decided that that single type should be byte strings because I want
>WSGI middleware and applications to be able to choose what encoding
>their output is. Passing unicode to the server would require some
>out-of-band method of telling the server which encoding to use per
>response, which seemed unacceptable.
I find the above baffling, since PEP 333 explicitly states that when
using unicode types, they're not actually supposed to *be* unicode
-- they're just bytes decoded with latin-1.
So, the server doesn't need to know "what encoding to use" -- it's
latin-1, plain and simple. (And it's an error for an application to
produce a unicode string that can't be encoded as latin-1.)
To be even more specific: an application that produces strings can
"choose what encoding to use" by encoding in it, then decoding those
bytes via latin-1. (This is more or less what Jython and IronPython
users are doing already, I believe.)
More information about the Web-SIG
mailing list