-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/03/2011 09:44 PM, Victor Stinner wrote: > Hi, > > In the PEP 3333, I read: > -------------- > import os, sys > > enc, esc = sys.getfilesystemencoding(), 'surrogateescape' > > def wsgi_string(u): > # Convert an environment variable to a WSGI "bytes-as-unicode" > string > return u.encode(enc, esc).decode('iso-8859-1') > > def run_with_cgi(application): > environ = {k: wsgi_string(v) for k,v in os.environ.items()} > environ['wsgi.input'] = sys.stdin > environ['wsgi.errors'] = sys.stderr > environ['wsgi.version'] = (1, 0) > ... > -------------- > > What is this horrible encoding "bytes-as-unicode"? os.environ is > supposed to be correctly decoded and contain valid unicode characters. > If WSGI uses another encoding than the locale encoding (which is a bad > idea), it should use os.environb and decodes keys and values using its > own encoding. > > If you really want to store bytes in unicode, str is not the right type: > use the bytes type and use os.environb instead.
I'm not clear on the semantics here, but I'm pretty sure you'll find that the web-SIG does know them well. I have CC'ed that list (via gmane). Note that Guido just recently wrote on that list that he considers that PEP to be de facto accepted. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0jSTUACgkQ+gerLs4ltQ4cCQCgyc9QsRfzC2lrtnDO0v8TvK6W rVwAnjvvwD47J1chgupqM3unt5c2jd6p =8LEf -----END PGP SIGNATURE----- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com