in Python3, json.loads() expects a string, while
HTTPConnection.getresponse() returns a byte-like object, so we need to
coerce it to str first.
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit
c79e1e1a525e08d55fd60c2333e8f5d4df603350)
import argparse
import contextlib
import logging
+import six
from six.moves import http_client
from six.moves.urllib.parse import urlparse
import json
if not (barbican_sec_resp.status >= 200 and
barbican_sec_resp.status < 300):
raise Exception("Cannot create secret")
- barbican_data = json.loads(barbican_sec_resp.read())
+ barbican_data = json.loads(six.ensure_str(barbican_sec_resp.read()))
if 'secret_ref' not in barbican_data:
raise ValueError("Malformed secret creation response")
secret_ref = barbican_data["secret_ref"]