diff options
author | Simon Glass <sjg@chromium.org> | 2019-05-17 22:00:45 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2019-07-10 16:52:58 -0600 |
commit | 58632a7f44cb0aef2c5cd4ede966c89abc430968 (patch) | |
tree | f64cfac9b3daf56eea842aa05c0f1ab4cd636906 /tools/binman | |
parent | 3c47e4105e0b467938660a986c261f2db10a2edd (diff) |
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 <sjg@chromium.org>
Diffstat (limited to 'tools/binman')
-rw-r--r-- | tools/binman/control.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/binman/control.py b/tools/binman/control.py index ce25eb5485..20186ee198 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)) |