From 810f7d07b80538382565ec73e4cb20845dfcd5a4 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 15 Dec 2023 14:26:53 -0600 Subject: [PATCH] base: Set response charset WebOb has started raising an exception when writing a Unicode string to `Response` objects if no charset is set. --- src/dcow/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dcow/base.py b/src/dcow/base.py index 4a14905..e13942c 100644 --- a/src/dcow/base.py +++ b/src/dcow/base.py @@ -30,10 +30,12 @@ class VariedResponse(milla.Response): context = {} if template is None or self.request.want == 'json': self.content_type = str('application/json') + self.charset = 'utf-8' json.dump(context, self.body_file) else: if self.request.want == 'xhtml': self.content_type = str('application/xhtml+xml') + self.charset = 'utf-8' self.render(template, context) def render(self, template, context=None):