Under certain circumstances, wsgiref.simple_server.demo_app may return unicode data, but that is prohibited by PEP-3333.
This happens if environ with unicode key is passed to demo_app. Unicode keys are then written to StringIO instance, automatically making its value unicode.
Type of environ keys is not strictly mandated by PEP-3333, however output of WSGI application is:
"When called by the server, the application object must return an iterable yielding zero or more bytestrings.", see http://www.python.org/dev/peps/pep-3333/#specification-details
Test case is attached. |