py3: decode bytes for json.loads()

In py 3.5 json.loads requires to have string as input, all bytes must be
decoded.

Note: python 3.6 supports bytes for json.loads()

https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti
2017-01-12 16:20:43 +01:00
parent 0eb5a0e0ec
commit 18337bf7f7
5 changed files with 59 additions and 6 deletions

View File

@@ -1101,7 +1101,8 @@ class JSONServerProxy(object):
)
try:
response = json_decode_binary(json.loads(response.decode('ascii')))
response = json_decode_binary(
json.loads(response.decode('utf-8')))
except ValueError as e:
raise JSONError(error=str(e))