[Web-SIG] Clarifications on Python 3.0 and WSGI.

Phillip J. Eby pje at telecommunity.com
Tue Mar 25 18:19:51 CET 2008


At 11:41 AM 3/25/2008 -0500, Ian Bicking wrote:
>Phillip J. Eby wrote:
>>At 11:04 AM 3/25/2008 -0500, Ian Bicking wrote:
>>>Phillip J. Eby wrote:
>>>>It says that in versions of Python where 'str is unicode' (i.e. 
>>>>Jython, IronPython, and Python 3000), then the specification 
>>>>should be read to define "string" as a unicode string whose 
>>>>characters can be expressed in latin-1.
>>>>Really, adding support for bytes is the stretch here.  In fact, 
>>>>I'd almost go so far as to say the heck with bytes support except 
>>>>for the response body.  I could easily consider headers to be text, instead.
>>>
>>>Latin-1?  How is this supposed to work at all?
>>Latin-1 is the encoding that can allow a unicode string to 
>>losslessly encode arbitrary bytes.  And that's how these things are 
>>handled (or should be handled, per the spec) in Jython and IronPython today.
>>In any case I only said I'd *almost* go so far as to say headers 
>>are text.  :)
>
>Are you proposing that we use a Latin-1 encoded string to hold bytes?

I'm not proposing it; I'm pointing out that the WSGI 1.0 spec 
*already requires this* for Jython, IronPython, *and* Python 3000, 
unless we amend it.

"""On Python platforms where the str or StringType type is in fact 
Unicode-based (e.g. Jython, IronPython, Python 3000, etc.), all 
"strings" referred to in this specification must contain only code 
points representable in ISO-8859-1 encoding (\u0000 through \u00FF, 
inclusive). It is a fatal error for an application to supply strings 
containing any other Unicode character or code point. Similarly, 
servers and gateways must not supply strings to an application 
containing any other Unicode characters."""

-- http://www.python.org/dev/peps/pep-0333/#unicode-issues

It's really a question of how we'd like to amend the spec to add 
support for bytes, since WSGI 1.0 *does not currently support bytes*.

If you think it currently supports bytes in any way, you are mistaken.



More information about the Web-SIG mailing list