From f16e6ea20899ed6acf7622258b75e42f591d58d7 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Tue, 12 Apr 2016 20:16:26 -0600 Subject: We don't need to explicitly set charset for text/* application/json however doesn't have a charset, so we just specify that as UTF-8 for the purpose of encoding the bytes. --- pyramid/httpexceptions.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 5500a0a29..213e4b980 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -255,7 +255,6 @@ ${body}''') if match == 'text/html': self.content_type = 'text/html' - self.charset = 'utf-8' escape = _html_escape page_template = self.html_template_obj br = '
' @@ -263,7 +262,7 @@ ${body}''') html_comment = '' % escape(comment) elif match == 'application/json': self.content_type = 'application/json' - self.charset = '' + self.charset = None escape = _no_escape br = '\n' if comment: @@ -283,7 +282,6 @@ ${body}''') page_template = JsonPageTemplate(self) else: self.content_type = 'text/plain' - self.charset = 'utf-8' escape = _no_escape page_template = self.plain_template_obj br = '\n' @@ -311,7 +309,7 @@ ${body}''') body = body_tmpl.substitute(args) page = page_template.substitute(status=self.status, body=body) if isinstance(page, text_type): - page = page.encode(self.charset) + page = page.encode(self.charset if self.charset else 'UTF-8') self.app_iter = [page] self.body = page -- cgit v1.2.3