From f9ae82009b09ca9955d7805773aadf9c8a6f96ff Mon Sep 17 00:00:00 2001 From: yhu6 Date: Wed, 19 Dec 2018 02:55:45 +0000 Subject: [PATCH] [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 --- fm-doc/fm_doc/check_missing_alarms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fm-doc/fm_doc/check_missing_alarms.py b/fm-doc/fm_doc/check_missing_alarms.py index 6a9262f5..8d81638a 100644 --- a/fm-doc/fm_doc/check_missing_alarms.py +++ b/fm-doc/fm_doc/check_missing_alarms.py @@ -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)