From 35e03a92e2543b8713ab0c2004ca4a0dcc8fd270 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 22 Sep 2013 09:04:20 -0700 Subject: [PATCH] Corrected several usage of keys() for Python 3 Under Python2 dict.keys() returns a list, under Python 3 it returns an iterator. Some places assumed that if they called keys() then it was safe to modify the dict in a loop. Corrected this by calling list(). Change-Id: I7638263f288dd20590bd751d09194a919b921545 --- novaclient/tests/v1_1/fakes.py | 2 +- novaclient/v1_1/quota_classes.py | 2 +- novaclient/v1_1/quotas.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py index 7b6bc119d..62224a2da 100644 --- a/novaclient/tests/v1_1/fakes.py +++ b/novaclient/tests/v1_1/fakes.py @@ -613,7 +613,7 @@ class FakeHTTPClient(base_client.HTTPClient): def get_flavors(self, **kw): status, header, flavors = self.get_flavors_detail(**kw) for flavor in flavors['flavors']: - for k in flavor.keys(): + for k in list(flavor): if k not in ['id', 'name']: del flavor[k] diff --git a/novaclient/v1_1/quota_classes.py b/novaclient/v1_1/quota_classes.py index 0b669bc2c..3f2908e5e 100644 --- a/novaclient/v1_1/quota_classes.py +++ b/novaclient/v1_1/quota_classes.py @@ -58,7 +58,7 @@ class QuotaClassSetManager(base.Manager): 'security_groups': security_groups, 'security_group_rules': security_group_rules}} - for key in body['quota_class_set'].keys(): + for key in list(body['quota_class_set']): if body['quota_class_set'][key] is None: body['quota_class_set'].pop(key) diff --git a/novaclient/v1_1/quotas.py b/novaclient/v1_1/quotas.py index 7c7ce54e3..bd5bd76e1 100644 --- a/novaclient/v1_1/quotas.py +++ b/novaclient/v1_1/quotas.py @@ -66,7 +66,7 @@ class QuotaSetManager(base.Manager): 'security_group_rules': security_group_rules, 'force': force}} - for key in body['quota_set'].keys(): + for key in list(body['quota_set']): if body['quota_set'][key] is None: body['quota_set'].pop(key)