From dabe872cbcfd815c63fe5816858923b1e908eefe Mon Sep 17 00:00:00 2001 From: dineshbhor Date: Tue, 21 Jun 2016 16:15:41 +0530 Subject: [PATCH] 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 --- troveclient/compat/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/troveclient/compat/exceptions.py b/troveclient/compat/exceptions.py index 7051bb40..c1023567 100644 --- a/troveclient/compat/exceptions.py +++ b/troveclient/compat/exceptions.py @@ -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)