This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients docs@python, eric.araujo, pje, r.david.murray, shimizukawa, terry.reedy
Date 2011-05-06.23:46:56
SpamBayes Score 1.3373197e-10
Marked as misclassified No
Message-id <1304725617.42.0.379435145255.issue11968@psf.upfronthosting.co.za>
In-reply-to
Content
Takayuki is correct, the status and header strings should, it seems, be 'native strings', not bytes.

The experimental proof is to run the current example code (I did so from IDLE editor window on WinXP) and then enter http://localhost:8000/
in a browser. Several error messages appear back in the shell window, like
AssertionError: Header names/values must be of type str (got b'Content-type')
Hit ^C to stop. Delete the b prefixes from the code. Rerun. Reaccess.
And the environment dict appears as promised:
TMP: C:\DOCUME~1\Terry\LOCALS~1\Temp
WATCOM: C:\temp\WatconPermanent
COMPUTERNAME: HP-PAVILION
wsgi.multiprocess: False
...
Takayuki, if you did the same thing, it would have been helpful if you had said so.

Neither version works in 3.1.3. No exception messages either. Firefox says unable to connect. I retried with 3.2.0 and patched example and it worked again.

Running this down in the docs was harder. In the example, function simple_app is a WSGI application object. The status and header objects are passed to the start_response function passed to simple_app after simple_app is passed to make_server. The manual (elsewhere) refers to PEP 3333 for the definition of WSGI app object. The 'start_response Callable' section says the status passed to start_response should be a string and that headers should be a list of tuples of header key and value, but it does not specify the type of the latter. The earlier 'Note on String Types says that headers are, for convenience, native-to-the-version strings while bodies are bytes. So the revised example that works matches the doc.

Phillip or David, can you verify that this is all as intended?
History
Date User Action Args
2011-05-06 23:46:57terry.reedysetrecipients: + terry.reedy, pje, eric.araujo, r.david.murray, docs@python, shimizukawa
2011-05-06 23:46:57terry.reedysetmessageid: <1304725617.42.0.379435145255.issue11968@psf.upfronthosting.co.za>
2011-05-06 23:46:56terry.reedylinkissue11968 messages
2011-05-06 23:46:56terry.reedycreate