misc: don't encode json in local charset in python 3 (#36515)

This commit is contained in:
Frédéric Péters 2019-11-15 13:31:47 +01:00
parent 5f8c243cd0
commit d0b2407738
1 changed files with 3 additions and 0 deletions

View File

@ -499,6 +499,9 @@ class JSONEncoder(json.JSONEncoder):
def json_encode_helper(d, charset):
'''Encode a JSON structure into local charset'''
if six.PY3:
# in python 3 we keep strings, no conversion to bytes
return d
if isinstance(d, unicode):
return d.encode(charset)
elif isinstance(d, list):