Issue 22899: http.server.BaseHTTPRequestHandler.parse_request (TypeError: decoding str is not supported) (original) (raw)
Issue22899
Created on 2014-11-18 23:16 by recharti, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg231350 - (view) | Author: Ryan Chartier (recharti) | Date: 2014-11-18 23:16 |
While the parse_request is handling the requestline, it tries to force the string into iso-8859-1 using an unsupported syntax. Line #274 in server.py requestline = str(self.raw_requestline, 'iso-8859-1') Obviously, python complains. TypeError: decoding str is not supported I'm running python 3.4.2 and the line is present in the 3.4.2 source I downloaded from the python.org today. That is all. | ||
msg231351 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2014-11-18 23:23 |
With the vanilla BaseHTTPRequestHandler, this shouldn't happen. self.raw_requestline is read from a socket file, which returns bytes, so they can be decoded using str(bytes, encoding). Can you please check if there are any third-party packages involved that call/subclass the classes from http.server and introduce a bytes/str confusion? They might not be correctly/completely ported to Python 3 in that case. In any case, a full traceback will be helpful to help debug this. | ||
msg231359 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2014-11-19 08:04 |
self.raw_requestline is read from self.rfile: self.raw_requestline = self.rfile.readline(65537) self.rfile is either socket stream self.rfile = self.connection.makefile('rb', self.rbufsize) or in-memory bytes stream self.rfile = BytesIO(self.packet) In both cases it is binary stream and produces bytes. I don't see a bug in the stdlib, it can be a bug in user code which sets self.rfile or self.raw_requestline to invalid value. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:10 | admin | set | github: 67088 |
2015-02-10 08:46:39 | serhiy.storchaka | set | status: pending -> closed |
2014-11-19 08:11:22 | georg.brandl | set | status: open -> pendingresolution: not a bug |
2014-11-19 08:04:43 | serhiy.storchaka | set | nosy: + serhiy.storchakamessages: + |
2014-11-18 23:23:19 | georg.brandl | set | nosy: + georg.brandlmessages: + |
2014-11-18 23:16:37 | recharti | create |