New submission from Jean-Marc Le Peuvedic <[email protected]>:
When running the built-in web server of web.py, the following error messages
appear when the HTTP client fetches a non existing CSS file:
TypeError('WSGI response header value 469 is not of type str.',)
Traceback (most recent call last):
File
"/home/jm/miniconda3/envs/REST/lib/python3.6/site-packages/web/wsgiserver/wsgiserver3.py",
line 1089, in communicate
req.respond()
File
"/home/jm/miniconda3/envs/REST/lib/python3.6/site-packages/web/wsgiserver/wsgiserver3.py",
line 877, in respond
self.server.gateway(self).respond()
File
"/home/jm/miniconda3/envs/REST/lib/python3.6/site-packages/web/wsgiserver/wsgiserver3.py",
line 1982, in respond
for chunk in response:
File
"/home/jm/miniconda3/envs/REST/lib/python3.6/site-packages/web/httpserver.py",
line 267, in __iter__
self.start_response(self.status, self.headers)
File
"/home/jm/miniconda3/envs/REST/lib/python3.6/site-packages/web/httpserver.py",
line 320, in xstart_response
out = start_response(status, response_headers, *args)
File
"/home/jm/miniconda3/envs/REST/lib/python3.6/site-packages/web/wsgiserver/wsgiserver3.py",
line 2029, in start_response
"WSGI response header value %r is not of type str." % v)
TypeError: WSGI response header value 469 is not of type str.
The faulty header is added by Python library, http/server.py.
Error added in version 3.4 according to comments.
Lines 467-471 in the attached file:
body = content.encode('UTF-8', 'replace')
self.send_header("Content-Type", self.error_content_type)
self.send_header('Content-Length', int(len(body)))
self.end_headers()
The value for 'Content-Length' is passed as an 'int', but only a 'str' is
acceptable.
In the latest revision of 'server.py', the same code appears line 453.
A possible correction is :
body = content.encode('UTF-8', 'replace')
self.send_header("Content-Type", self.error_content_type)
self.send_header('Content-Length', str(int(len(body))))
self.end_headers()
----------
components: Library (Lib)
files: server.py
messages: 317813
nosy: jmlp
priority: normal
severity: normal
status: open
title: Web.py wsgiserver3.py raises TypeError when CSS file is not found
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47616/server.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33663>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com