misc: don't encode json data in py3 (#36515)

This commit is contained in:
Frédéric Péters 2019-11-12 21:31:56 +01:00
parent db6fe5f504
commit 5da68239d3
1 changed files with 3 additions and 1 deletions

View File

@ -244,7 +244,7 @@ def site_encode(s):
return None
if isinstance(s, str):
return s
if not isinstance(s, unicode):
if not isinstance(s, six.string_types):
s = force_text(s)
return s.encode(get_publisher().site_charset)
@ -516,6 +516,8 @@ def json_encode_helper(d, charset):
return d
def json_loads(value, charset=None):
if six.PY3:
return json.loads(value)
charset = (get_publisher() and get_publisher().site_charset) or 'utf-8'
return json_encode_helper(json.loads(value), charset)