From 690e1824a03c2f6d8a4c84efda46f3fa376ca508 Mon Sep 17 00:00:00 2001 From: Nate Johnston Date: Thu, 30 May 2019 08:53:31 -0400 Subject: [PATCH] Use list instead of six.viewkeys to avoid py2 to py3 problems This change fixes an 'RuntimeError: dictionary changed size during iteration' error that is raised because of different behaviour between python2 and python3. An earlier attempt [1] to use the six library did not fix the issue. [1] https://review.opendev.org/660427 Resolves-Bug: #1829304 Change-Id: Ic4c5790a5d66e10a606327f4f4e4c92611f161d8 (cherry picked from commit a65ae9c81eea909133446c0be4d54ce389f6e0e1) --- neutron/pecan_wsgi/hooks/policy_enforcement.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/neutron/pecan_wsgi/hooks/policy_enforcement.py b/neutron/pecan_wsgi/hooks/policy_enforcement.py index 9f1501fe0ca..ba69da15942 100644 --- a/neutron/pecan_wsgi/hooks/policy_enforcement.py +++ b/neutron/pecan_wsgi/hooks/policy_enforcement.py @@ -19,7 +19,6 @@ from oslo_log import log as logging from oslo_policy import policy as oslo_policy from oslo_utils import excutils from pecan import hooks -import six import webob from neutron._i18n import _ @@ -122,7 +121,7 @@ class PolicyHook(hooks.PecanHook): original_resources.append(resource_obj) obj = copy.copy(resource_obj) obj.update(item) - obj[const.ATTRIBUTES_TO_UPDATE] = six.viewkeys(item) + obj[const.ATTRIBUTES_TO_UPDATE] = list(item) # Put back the item in the list so that policies could be # enforced resources_copy.append(obj) @@ -224,7 +223,7 @@ class PolicyHook(hooks.PecanHook): to see them. """ attributes_to_exclude = [] - for attr_name in six.viewkeys(data): + for attr_name in list(data): # TODO(amotoki): All attribute maps have tenant_id and # it determines excluded attributes based on tenant_id. # We need to migrate tenant_id to project_id later