rpc: fix crash in verbose mode

Fix a crash caused by feeding incorrect data to `json.dumps()` in
`JSONServerProxy.__request()` introduced by commit
8159c2883b.

https://pagure.io/freeipa/issue/6734

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Jan Cholasta 2017-03-10 09:33:15 +00:00 committed by Martin Basti
parent 2fc9feddd0
commit 8295848bfe

View File

@ -1136,16 +1136,17 @@ class JSONServerProxy(object):
verbose=self.__verbose >= 3,
)
if print_json:
root_logger.info(
'Response: %s',
json.dumps(json.loads(response), sort_keys=True, indent=4)
)
try:
response = json_decode_binary(response)
except ValueError as e:
raise JSONError(error=str(e))
if print_json:
root_logger.info(
'Response: %s',
json.dumps(response, sort_keys=True, indent=4)
)
error = response.get('error')
if error:
try: