Merge "Revert "Ensure the json result type is bytes on Python 3""

This commit is contained in:
Jenkins 2016-03-11 14:25:04 +00:00 committed by Gerrit Code Review
commit cc89fc3174
7 changed files with 9 additions and 10 deletions

View File

@ -197,13 +197,13 @@ def serialize_remote_exception(failure_info, log_failure=True):
'kwargs': kwargs
}
json_data = jsonutils.dump_as_bytes(data)
json_data = jsonutils.dumps(data)
return json_data
def deserialize_remote_exception(data, allowed_remote_exmods):
failure = jsonutils.loads(data)
failure = jsonutils.loads(six.text_type(data))
trace = failure.get('tb', [])
message = failure.get('message', "") + "\n" + "\n".join(trace)
@ -284,7 +284,7 @@ def serialize_msg(raw_msg):
# NOTE(russellb) See the docstring for _RPC_ENVELOPE_VERSION for more
# information about this format.
msg = {_VERSION_KEY: _RPC_ENVELOPE_VERSION,
_MESSAGE_KEY: jsonutils.dump_as_bytes(raw_msg)}
_MESSAGE_KEY: jsonutils.dumps(raw_msg)}
return msg

View File

@ -128,7 +128,7 @@ class Connection(object):
def _send_and_retry(self, message, topic, retry):
current_retry = 0
if not isinstance(message, str):
message = jsonutils.dump_as_bytes(message)
message = jsonutils.dumps(message)
while message is not None:
try:
self._send(message, topic)

View File

@ -56,7 +56,7 @@ def marshal_response(reply=None, failure=None):
data = {"failure": failure}
else:
data = {"response": reply}
msg.body = jsonutils.dump_as_bytes(data)
msg.body = jsonutils.dumps(data)
return msg
@ -80,7 +80,7 @@ def marshal_request(request, context, envelope):
"request": request,
"context": context
}
msg.body = jsonutils.dump_as_bytes(data)
msg.body = jsonutils.dumps(data)
return msg

View File

@ -40,7 +40,6 @@ class LogDriver(notifier.Driver):
message['event_type']))
method = getattr(logger, priority.lower(), None)
if method:
# NOTE: The logger needs json formatted string instead of bytes
method(jsonutils.dumps(strutils.mask_dict_password(message)))
else:
warnings.warn('Unable to log message as notify cannot find a '

View File

@ -145,7 +145,7 @@ class TestKafkaConnection(test_utils.BaseTestCase):
conn.consumer = mock.MagicMock()
conn.consumer.fetch_messages = mock.MagicMock(
return_value=iter([jsonutils.dump_as_bytes(fake_message)]))
return_value=iter([jsonutils.dumps(fake_message)]))
self.assertEqual(fake_message, jsonutils.loads(conn.consume()[0]))
self.assertEqual(1, len(conn.consumer.fetch_messages.mock_calls))

View File

@ -897,7 +897,7 @@ class TestReplyWireFormat(test_utils.BaseTestCase):
'_reply_q': 'reply_' + uuid.uuid4().hex,
})
msg['oslo.message'] = jsonutils.dump_as_bytes(msg['oslo.message'])
msg['oslo.message'] = jsonutils.dumps(msg['oslo.message'])
producer.publish(msg)

View File

@ -293,7 +293,7 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
'kwargs': self.kwargs,
}
serialized = jsonutils.dump_as_bytes(failure)
serialized = jsonutils.dumps(failure)
ex = exceptions.deserialize_remote_exception(serialized, self.allowed)