runtime: fix lchan deletion in method reset

When we perform a reset while multiple channels are open (this is in
particular the case when parsing real world traces with pySim-trace). To
delete those channels during the reset we iterate over the dictionary
using the keys and delete the channels one by one. However, this must
not be done using the keys as index directly. Python will then throw an
exception: "RuntimeError: dictionary changed size during iteration".

Instead using the keys directly we should cast them into a list and then
using that list for the iteration.

Related: OS#6094
Change-Id: I430ef216cf847ffbde2809f492ee9ed9030343b6
This commit is contained in:
Philipp Maier
2023-07-21 11:38:26 +02:00
parent 7d86fe1d8a
commit 92b9356ed2

View File

@@ -124,7 +124,7 @@ class RuntimeState:
cmd_app : Command Application State (for unregistering old file commands)
"""
# delete all lchan != 0 (basic lchan)
for lchan_nr in self.lchan.keys():
for lchan_nr in list(self.lchan.keys()):
if lchan_nr == 0:
continue
del self.lchan[lchan_nr]