[Kimchi-devel] [PATCH] Remove 'encoding=iso-8859-1' from json.dumps()

Mark Wu wudxw at linux.vnet.ibm.com
Wed Jan 22 11:09:44 UTC 2014


The encoding option for json.dumps() is used to indicate the charsets
of the passed in str. Currently,  we use the encoding of iso-8859-1,
but actually we don't have any data encoded in iso-8859-1. It doesn't
cause any problem because the strings in the data passed are ascii chars
or unicode. If we pass a utf-8 str, it will canse an expected result.
So we could remove the option, and after that it can accept utf-8 str too
because json.dumps use utf-8 as default encoding.

Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
---
 src/kimchi/template.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/kimchi/template.py b/src/kimchi/template.py
index 1f19c4a..f854657 100644
--- a/src/kimchi/template.py
+++ b/src/kimchi/template.py
@@ -84,9 +84,7 @@ def can_accept_html():
 def render(resource, data):
     if can_accept('application/json'):
         cherrypy.response.headers['Content-Type'] = 'application/json;charset=utf-8'
-        return json.dumps(data, indent=2,
-                          separators=(',', ':'),
-                          encoding='iso-8859-1')
+        return json.dumps(data, indent=2, separators=(',', ':'))
     elif can_accept_html():
         filename = config.get_template_path(resource)
         try:
-- 
1.8.4.2




More information about the Kimchi-devel mailing list