[Web-SIG] decoding environ
Antoine Pitrou
solipsis at pitrou.net
Sat Jul 17 13:13:15 CEST 2010
Ian Bicking <ianb at ...> writes:
>
> So... there's been some discussion of WSGI on Python 3 lately.
> I'm not feeling as pessimistic as some people, I feel like we were close
> but just didn't *quite* get there.
> Here's my thoughts:
> * Everyone agrees keys in the environ should be native strings
I don't know how that related to WSGI but it should be noted that Python 3.2
comes with two synchronized views of the environment: os.environ (str -> str
mapping) and os.environb (bytes -> bytes mapping).
See http://docs.python.org/dev/library/os.html#os.environ
Also, the way os.environ is decoded from bytes values involves the
"surrogateescape" error handler, which ensures that non-decodeable bytes get
their own unicode escape sequences, and can get re-encoded losslessly:
http://www.python.org/dev/peps/pep-0383/
Regards
Antoine.
More information about the Web-SIG
mailing list