Change bytes to str in servers_client for python3
In python3, the response body of clients will be of type bytes, but jsonschema.validate expects parameter of type str, so we need change bytes to str when needed, otherwise we will get errors like "HTTP response body is invalid (b'' is not of type 'object', 'string'" Change-Id: If4cad1b0f706aeb5f83931cb6928806a2c5cee8e Closes-Bug: #1864625
This commit is contained in:
parent
2844774bb2
commit
be86aec05d
@ -209,6 +209,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
|
||||
post_body)
|
||||
if body:
|
||||
body = json.loads(body)
|
||||
else:
|
||||
if isinstance(body, bytes):
|
||||
body = body.decode('utf-8')
|
||||
self.validate_response(schema, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user