Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a case where the response could become unicode; fix the docstring…

… patching when using python -O
  • Loading branch information...
commit 164f460215611e328468daef0fade38330a20c9b 1 parent 74d9536
@ianb ianb authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 weberror/errormiddleware.py
View
6 weberror/errormiddleware.py
@@ -165,10 +165,12 @@ def __call__(self, environ, start_response):
exc_info = sys.exc_info()
try:
start_response('500 Internal Server Error',
- [('content-type', 'text/html')],
+ [('content-type', 'text/html; charset=utf8')],
exc_info)
# @@: it would be nice to deal with bad content types here
response = self.exception_handler(exc_info, environ)
+ if isinstance(response, unicode):
+ response = response.encode('utf8')
return [response]
finally:
# clean up locals...
@@ -480,7 +482,7 @@ def error_template(head_html, exception, extra):
def make_error_middleware(app, global_conf, **kw):
return ErrorMiddleware(app, global_conf=global_conf, **kw)
-doc_lines = ErrorMiddleware.__doc__.splitlines(True)
+doc_lines = (ErrorMiddleware.__doc__ or '').splitlines(True)
for i in range(len(doc_lines)):
if doc_lines[i].strip().startswith('Settings'):
make_error_middleware.__doc__ = ''.join(doc_lines[i:])
Please sign in to comment.
Something went wrong with that request. Please try again.