From 6dda6f306f44f68c437176428eb041d4fd862505 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 26 Aug 2014 18:21:47 +0000 Subject: [PATCH] Fix error when logging http response with python 3 Python 3 changed the semantics of dict.items() [0], which now returns a iterable 'view' instead of a list of tuples. This has the repercussion that you can no longer check for membership of a key using: key in dict.items() This patch simply replaces that check with a test for the key existing in the dict itself, rather than the items. [0] http://legacy.python.org/dev/peps/pep-3106/ Closes-Bug: 1359880 Change-Id: I7c59b0432725b660c9fa7270cde2e07bf3ea77db --- glanceclient/common/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index d5fa1d39..4023f038 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -119,7 +119,7 @@ class HTTPClient(object): status = (resp.raw.version / 10.0, resp.status_code, resp.reason) dump = ['\nHTTP/%.1f %s %s' % status] headers = resp.headers.items() - if 'X-Auth-Token' in headers: + if 'X-Auth-Token' in resp.headers: headers['X-Auth-Token'] = '*' * 3 dump.extend(['%s: %s' % (k, v) for k, v in headers]) dump.append('')