From 219c334f0169fe485b05bb9e5ae99edd9685dfb1 Mon Sep 17 00:00:00 2001 From: xiexs Date: Thu, 19 May 2016 00:11:50 -0400 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: Ia6c0783ca8c8514a06defbeed0fa9ef24bbd9d4a Closes-Bug: #1583419 --- cinderclient/openstack/common/apiclient/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cinderclient/openstack/common/apiclient/exceptions.py b/cinderclient/openstack/common/apiclient/exceptions.py index 4776d5872..565c47e8a 100644 --- a/cinderclient/openstack/common/apiclient/exceptions.py +++ b/cinderclient/openstack/common/apiclient/exceptions.py @@ -426,7 +426,7 @@ def from_response(response, method, url): pass else: if hasattr(body, "keys"): - error = body[body.keys()[0]] + error = body[list(body.keys())[0]] kwargs["message"] = error.get("message", None) kwargs["details"] = error.get("details", None) elif content_type.startswith("text/"):