Browse Source

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
tags/2.16.0
Alex Gaynor 5 years ago
parent
commit
35e03a92e2
3 changed files with 3 additions and 3 deletions
  1. 1
    1
      novaclient/tests/v1_1/fakes.py
  2. 1
    1
      novaclient/v1_1/quota_classes.py
  3. 1
    1
      novaclient/v1_1/quotas.py

+ 1
- 1
novaclient/tests/v1_1/fakes.py View File

@@ -613,7 +613,7 @@ class FakeHTTPClient(base_client.HTTPClient):
613 613
     def get_flavors(self, **kw):
614 614
         status, header, flavors = self.get_flavors_detail(**kw)
615 615
         for flavor in flavors['flavors']:
616
-            for k in flavor.keys():
616
+            for k in list(flavor):
617 617
                 if k not in ['id', 'name']:
618 618
                     del flavor[k]
619 619
 

+ 1
- 1
novaclient/v1_1/quota_classes.py View File

@@ -58,7 +58,7 @@ class QuotaClassSetManager(base.Manager):
58 58
                 'security_groups': security_groups,
59 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 62
             if body['quota_class_set'][key] is None:
63 63
                 body['quota_class_set'].pop(key)
64 64
 

+ 1
- 1
novaclient/v1_1/quotas.py View File

@@ -66,7 +66,7 @@ class QuotaSetManager(base.Manager):
66 66
                 'security_group_rules': security_group_rules,
67 67
                 'force': force}}
68 68
 
69
-        for key in body['quota_set'].keys():
69
+        for key in list(body['quota_set']):
70 70
             if body['quota_set'][key] is None:
71 71
                 body['quota_set'].pop(key)
72 72
 

Loading…
Cancel
Save