Make dict.keys() PY3 compatible

The dict.keys()[0] will raise a TypeError in PY3,
as dict.keys() doesn't return a list any more in PY3
but a view of list.

Change-Id: Id9c7d3725c01bd0a193d8fc6705443efe9c25c34
Partially implements: blueprint trove-python3
Closes-Bug: #1583419
This commit is contained in:
dineshbhor 2016-06-21 16:15:41 +05:30 committed by Peter Stachowski
parent f0a6d7ff7a
commit dabe872cbc

View File

@ -163,7 +163,7 @@ def from_response(response, body):
message = "n/a"
details = "n/a"
if hasattr(body, 'keys'):
error = body[body.keys()[0]]
error = body[list(body.keys())[0]]
message = error.get('message', None)
details = error.get('details', None)
return cls(code=response.status, message=message, details=details)