[Web-SIG] WSGI, Python 3 and Unicode

Phillip J. Eby pje at telecommunity.com
Fri Dec 7 01:15:26 CET 2007


At 10:13 AM 12/7/2007 +1100, Graham Dumpleton wrote:
>Has anyone had any thoughts about how WSGI is going to made to work
>with Python 3?
>
> >From what I understand about changes in Python 3, the main issue seems
>to be the removal of string type in its current form.
>
>This is an issue as WSGI specification currently states that status,
>header names/values and the items returned by the iterable must all be
>string instances. This is done to ensure that the application has done
>any conversions from Unicode, where knowledge about encoding would be
>known, before being passed to WSGI adapter.
>
>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?

WSGI already copes, actually.  Note that Jython and IronPython have 
this issue today, and see:

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

"""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."""




More information about the Web-SIG mailing list