summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-09-22 09:04:20 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-09-22 09:04:20 -0700
commit35e03a92e2543b8713ab0c2004ca4a0dcc8fd270 (patch)
tree68155d60b485917cf7713f78326428f11d312118
parent8deaf3769d6076851003668f4c53d478bb3ff2c5 (diff)
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
Notes
Notes (review): Verified+2: Jenkins Code-Review+1: Chuck Short <chuck.short@canonical.com> Code-Review+2: Kevin L. Mitchell <kevin.mitchell@rackspace.com> Approved+1: Russell Bryant <rbryant@redhat.com> Code-Review+2: Russell Bryant <rbryant@redhat.com> Code-Review-1: David Ripton <dripton@redhat.com> Code-Review+1: Kui Shi <skuicloud@gmail.com> Code-Review+1: Brian Curtin <brian.curtin@rackspace.com> Submitted-by: Jenkins Submitted-at: Tue, 24 Sep 2013 00:24:21 +0000 Reviewed-on: https://review.openstack.org/47750 Project: openstack/python-novaclient Branch: refs/heads/master
-rw-r--r--novaclient/tests/v1_1/fakes.py2
-rw-r--r--novaclient/v1_1/quota_classes.py2
-rw-r--r--novaclient/v1_1/quotas.py2
3 files changed, 3 insertions, 3 deletions
diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py
index 7b6bc11..62224a2 100644
--- a/novaclient/tests/v1_1/fakes.py
+++ b/novaclient/tests/v1_1/fakes.py
@@ -613,7 +613,7 @@ class FakeHTTPClient(base_client.HTTPClient):
613 def get_flavors(self, **kw): 613 def get_flavors(self, **kw):
614 status, header, flavors = self.get_flavors_detail(**kw) 614 status, header, flavors = self.get_flavors_detail(**kw)
615 for flavor in flavors['flavors']: 615 for flavor in flavors['flavors']:
616 for k in flavor.keys(): 616 for k in list(flavor):
617 if k not in ['id', 'name']: 617 if k not in ['id', 'name']:
618 del flavor[k] 618 del flavor[k]
619 619
diff --git a/novaclient/v1_1/quota_classes.py b/novaclient/v1_1/quota_classes.py
index 0b669bc..3f2908e 100644
--- a/novaclient/v1_1/quota_classes.py
+++ b/novaclient/v1_1/quota_classes.py
@@ -58,7 +58,7 @@ class QuotaClassSetManager(base.Manager):
58 'security_groups': security_groups, 58 'security_groups': security_groups,
59 'security_group_rules': security_group_rules}} 59 'security_group_rules': security_group_rules}}
60 60
61 for key in body['quota_class_set'].keys(): 61 for key in list(body['quota_class_set']):
62 if body['quota_class_set'][key] is None: 62 if body['quota_class_set'][key] is None:
63 body['quota_class_set'].pop(key) 63 body['quota_class_set'].pop(key)
64 64
diff --git a/novaclient/v1_1/quotas.py b/novaclient/v1_1/quotas.py
index 7c7ce54..bd5bd76 100644
--- a/novaclient/v1_1/quotas.py
+++ b/novaclient/v1_1/quotas.py
@@ -66,7 +66,7 @@ class QuotaSetManager(base.Manager):
66 'security_group_rules': security_group_rules, 66 'security_group_rules': security_group_rules,
67 'force': force}} 67 'force': force}}
68 68
69 for key in body['quota_set'].keys(): 69 for key in list(body['quota_set']):
70 if body['quota_set'][key] is None: 70 if body['quota_set'][key] is None:
71 body['quota_set'].pop(key) 71 body['quota_set'].pop(key)
72 72