diff options
author | Martin Basti <mbasti@redhat.com> | 2017-01-12 16:20:43 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-01-24 13:25:47 +0100 |
commit | 18337bf7f7c31a47fe0c7280f82fca043b548bd5 (patch) | |
tree | 4878fdfa1a49582d93249bcc8ce157dd9bba1ac2 /ipaserver/plugins/dogtag.py | |
parent | 0eb5a0e0ec2d232d2921ae5f9e8d0885146a5610 (diff) | |
download | freeipa-18337bf7f7c31a47fe0c7280f82fca043b548bd5.tar.gz freeipa-18337bf7f7c31a47fe0c7280f82fca043b548bd5.tar.xz freeipa-18337bf7f7c31a47fe0c7280f82fca043b548bd5.zip |
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>
Diffstat (limited to 'ipaserver/plugins/dogtag.py')
-rw-r--r-- | ipaserver/plugins/dogtag.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py index 142f838e1..fbfe60840 100644 --- a/ipaserver/plugins/dogtag.py +++ b/ipaserver/plugins/dogtag.py @@ -1232,7 +1232,8 @@ class RestClient(Backend): @staticmethod def _parse_dogtag_error(body): try: - return pki.PKIException.from_json(json.loads(body)) + return pki.PKIException.from_json( + json.loads(ipautil.decode_json(body))) except Exception: return None @@ -1667,7 +1668,7 @@ class ra(rabase.rabase, RestClient): ) try: - resp_obj = json.loads(http_body) + resp_obj = json.loads(ipautil.decode_json(http_body)) except ValueError: raise errors.RemoteRetrieveError(reason=_("Response from CA was not valid JSON")) @@ -2115,7 +2116,7 @@ class ra_lightweight_ca(RestClient): body=json.dumps({"parentID": "host-authority", "dn": unicode(dn)}), ) try: - return json.loads(resp_body) + return json.loads(ipautil.decode_json(resp_body)) except Exception as e: self.log.debug(e, exc_info=True) raise errors.RemoteRetrieveError( @@ -2125,7 +2126,7 @@ class ra_lightweight_ca(RestClient): _status, _resp_headers, resp_body = self._ssldo( 'GET', ca_id, headers={'Accept': 'application/json'}) try: - return json.loads(resp_body) + return json.loads(ipautil.decode_json(resp_body)) except Exception as e: self.log.debug(e, exc_info=True) raise errors.RemoteRetrieveError( |