Exercise 2: A Bytes-Type Contract Violation — Possible Solution ==================================================================== THE APPLICATION ------------------------------ def string_body_app(environ, start_response): start_response('200 OK', [('Content-type', 'text/plain')]) return ["this is a plain str, not bytes"] # violates the real WSGI contract start_response is called correctly here - the violation is specifically in the returned iterable's own element type: PEP 3333 requires "an iterable yielding zero or more bytestrings," and a plain Python str is not a bytestring. THE REAL, VERIFIED RESULT ------------------------------ Run against a real wsgiref server and hit with a real urllib request: Server-side traceback: AssertionError: write() argument must be a bytes instance Client-side result: urllib.error.HTTPError: HTTP Error 500: Internal Server Error WHY THIS WORKS AS AN ANSWER ------------------------------ It isolates exactly one contract violation (the body's element type) while keeping start_response's own call correct, then reports both the real server-side AssertionError and the real client-side HTTPError - showing wsgiref actively enforces the bytes-only body requirement at runtime rather than silently accepting a str, and that the failure surfaces to a real client as a genuine HTTP 500, not a hang or a malformed response.