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 a65ae9c81e
)
This commit is contained in:
parent
6f0996a88b
commit
690e1824a0
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue