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

Aline Manera alinefm at linux.vnet.ibm.com
Wed Jan 22 15:42:51 UTC 2014


On 01/22/2014 09:17 AM, Sheldon wrote:
> On 01/22/2014 07:09 PM, Mark Wu wrote:
>> 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.
> canse?
>

I will fix the typo and apply.

>> 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:
>
>




More information about the Kimchi-devel mailing list