[fm-doc] bug-fix: change a "dictionary" while iterating it

issue: in ~/fm-doc/fm_doc/check_missing_alarms.py, there is
a for-loop iterating the dict "events", however inside this
loop, some elements are being popped out, and elements with
new keys are being added dynamically. This is not safe and
would bring unpredictable behavior with different versions
of Python and "Collections".

check_missing_alarms.py is triggered to run at Build stage
(defined in fm-doc.spec) when generating "fm-doc.*.tis.rpm".

Test for fix:
1. rebuild on "fm-doc.*.tis.rpm" by "# build-pkgs fm-doc"
2. check the rpm build log and assure the code be executed
correctly with expected check results.
3. run this script with different Python versions on other
Linux hosts and assure it works well.

Closes-Bug: 1809064

Change-Id: Ieb07ae944037c2eb33dda414e870702a9d248d83
Signed-off-by: yhu6 <yong.hu@intel.com>
This commit is contained in:
yhu6 2018-12-19 02:55:45 +00:00
parent e8d9da24c8
commit f9ae82009b
1 changed files with 1 additions and 1 deletions

View File

@ -16,7 +16,7 @@ FM_ALARM_H = "fmAlarm.h"
def get_events_alarm_list(events):
for alarm_id in events:
for alarm_id in list(events):
if isinstance(alarm_id, float):
formatted_alarm_id = "{:.3f}".format(alarm_id) # force 3 digits after the point, to include trailing zero's (ex.: 200.010)
events[formatted_alarm_id] = events.pop(alarm_id)