From 58632a7f44cb0aef2c5cd4ede966c89abc430968 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 17 May 2019 22:00:45 -0600 Subject: [PATCH] binman: Avoid changing a dict during iteration This code works OK in Python 2 but Python 3 complains. Adjust it to avoid deleting elements from a dict while iterating through it. Signed-off-by: Simon Glass --- tools/binman/control.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index ce25eb5..20186ee 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -131,10 +131,13 @@ def Binman(options, args): if options.image: skip = [] + new_images = OrderedDict() for name, image in images.items(): - if name not in options.image: - del images[name] + if name in options.image: + new_images[name] = image + else: skip.append(name) + images = new_images if skip and options.verbosity >= 2: print('Skipping images: %s' % ', '.join(skip)) -- 2.7.4