New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot start wsgiref simple server in Py3k #47598
Comments
The wsgiref "simple server" module has a demo server, which fails to To verify this, just go into the Lib/wsgiref directory, and run: This opens your web browser and points it at the server, and you get the ValueError: need more than 1 value to unpack I fixed a number of issues which simply killed the server:
Unfortunately, the final issue is a bit harder to fix. It seems when I TypeError: send() argument 1 must be bytes or read-only buffer, not str However in the test case, it opens a text stream, so handlers.py works fine. The following *HACK* fixes it so the demo server works, but breaks the --- Lib/wsgiref/handlers.py (revision 64895)
+++ Lib/wsgiref/handlers.py (working copy)
@@ -382,8 +382,8 @@
self.environ.update(self.base_env)
def _write(self,data):
- self.stdout.write(data)
- self._write = self.stdout.write
+ self.stdout.write(data.encode('utf-8'))
+ #self._write = self.stdout.write
I can't figure out right away what to do about this, but the best
solution would be to get the demo server to open the socket in text mode. In any case, the patch is attached for branch /branches/py3k, revision Commit log:
|
The encoding must be latin-1, not utf-8, and the stream must be binary I have no idea how to deal with the test suite, and don't have time at |
Are you saying the stream passed to _write SHOULD always be a binary (I'm not sure where the stream comes from, but we should guarantee it's Also, why Latin-1? |
For the "why Latin-1", read the WSGI spec's explanation of how I suppose that you *could* make it a text stream with Latin-1 |
Wow, I read the WSGI spec. That seems very strange that it says "HTTP I assume then that the ISO-8859-1 characters the WSGI functions receive But in any event, the PEP has spoken, so we stick with Latin-1. With respect to the text/binary stream, I think it would be best if it's |
HTTP is defined as a stream of bytes; the fact that you can specify |
Also reported in bpo-3795. |
Not any time soon; I don't currently use Py3K and can't even vouch for |
There's a proper patch in bpo-4718, marking this one in duplicate. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: