[Web-SIG] WSGI, Python 3 and Unicode

Adam Atlas adam at atlas.st
Fri Dec 7 02:08:04 CET 2007

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.

I was going to say that the gateway could accept Unicode objects if  
the user-agent sent a comprehensible Accept-Charset header, and  
thereby encode application output to the client's preferred character  
set on the fly (or to ISO-8859-1 if no Accept-Charset is provided),  
but that would complicate things for people writing gateways (and  
would be too implicit). It could be useful, but it would make more  
sense as a simple decorator for (almost-)WSGI applications. Perhaps it  
could go in wsgiref.

More information about the Web-SIG mailing list