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:

committed by
Peter Stachowski

parent
f0a6d7ff7a
commit
dabe872cbc
@@ -163,7 +163,7 @@ def from_response(response, body):
|
|||||||
message = "n/a"
|
message = "n/a"
|
||||||
details = "n/a"
|
details = "n/a"
|
||||||
if hasattr(body, 'keys'):
|
if hasattr(body, 'keys'):
|
||||||
error = body[body.keys()[0]]
|
error = body[list(body.keys())[0]]
|
||||||
message = error.get('message', None)
|
message = error.get('message', None)
|
||||||
details = error.get('details', None)
|
details = error.get('details', None)
|
||||||
return cls(code=response.status, message=message, details=details)
|
return cls(code=response.status, message=message, details=details)
|
||||||
|
Reference in New Issue
Block a user