publishers: iterate over copy of checkstyle data

Iterate over a copy of checkstyle's data in both Python 2.x and Python
3.x. Python 3.5 does not allow us to modify the data OrderedDict during
a loop.

Note that this patch addresses the following error message which
is new in Python 3.5. That is, you need to be using Python 3.5+
to reproduce this error.

    RuntimeError: OrderedDict mutated during iteration

This bug is described at
https://storyboard.openstack.org/#!/story/2000436

Change-Id: Ia000279c38b991f4194cb587160b7a174872d991
This commit is contained in:
Ken Dreyer
2015-12-02 08:44:20 -07:00
parent c62b0a10d0
commit b2324d3507

View File

@@ -1354,11 +1354,9 @@ def checkstyle(parser, xml_parent, data):
"""Helper to convert settings from one key to another
"""
for old_key, value in data.items():
for old_key in list(data.keys()):
if old_key in lookup:
# Insert value if key does not already exists
data.setdefault(lookup[old_key], value)
data.setdefault(lookup[old_key], data[old_key])
del data[old_key]
xml_element = XML.SubElement(xml_parent,