[U-Boot] [PATCH 07/21] binman: Use items() instead of iteritems()

Simon Glass sjg at chromium.org
Tue May 14 21:53:41 UTC 2019


Python 3 requires this, and Python 2 allows it. Convert the code over to
ensure compatibility with Python 3.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/binman/bsection.py  | 2 +-
 tools/binman/control.py   | 2 +-
 tools/binman/elf.py       | 4 ++--
 tools/binman/etype/gbb.py | 2 +-
 tools/binman/ftest.py     | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index be67ff957e..3ca0592fe1 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -253,7 +253,7 @@ class Section(object):
         """
         for entry in self._entries.values():
             offset_dict = entry.GetOffsets()
-            for name, info in offset_dict.iteritems():
+            for name, info in offset_dict.items():
                 self._SetEntryOffsetSize(name, *info)
 
     def PackEntries(self):
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 8f7f906860..ce25eb5485 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -131,7 +131,7 @@ def Binman(options, args):
 
             if options.image:
                 skip = []
-                for name, image in images.iteritems():
+                for name, image in images.items():
                     if name not in options.image:
                         del images[name]
                         skip.append(name)
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 97df8e32c5..828681d76d 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -59,7 +59,7 @@ def GetSymbols(fname, patterns):
                                 flags[1] == 'w')
 
     # Sort dict by address
-    return OrderedDict(sorted(syms.iteritems(), key=lambda x: x[1].address))
+    return OrderedDict(sorted(syms.items(), key=lambda x: x[1].address))
 
 def GetSymbolAddress(fname, sym_name):
     """Get a value of a symbol from an ELF file
@@ -98,7 +98,7 @@ def LookupAndWriteSymbols(elf_fname, entry, section):
     base = syms.get('__image_copy_start')
     if not base:
         return
-    for name, sym in syms.iteritems():
+    for name, sym in syms.items():
         if name.startswith('_binman'):
             msg = ("Section '%s': Symbol '%s'\n   in entry '%s'" %
                    (section.GetPath(), name, entry.GetPath()))
diff --git a/tools/binman/etype/gbb.py b/tools/binman/etype/gbb.py
index 8fe10f4713..a94c0fca9d 100644
--- a/tools/binman/etype/gbb.py
+++ b/tools/binman/etype/gbb.py
@@ -64,7 +64,7 @@ class Entry_gbb(Entry):
         self.gbb_flags = 0
         flags_node = node.FindNode('flags')
         if flags_node:
-            for flag, value in gbb_flag_properties.iteritems():
+            for flag, value in gbb_flag_properties.items():
                 if fdt_util.GetBool(flags_node, flag):
                     self.gbb_flags |= value
 
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index daea1ea138..7cf17526a7 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -214,7 +214,7 @@ class TestFunctional(unittest.TestCase):
         if verbosity is not None:
             args.append('-v%d' % verbosity)
         if entry_args:
-            for arg, value in entry_args.iteritems():
+            for arg, value in entry_args.items():
                 args.append('-a%s=%s' % (arg, value))
         if images:
             for image in images:
-- 
2.21.0.1020.gf2820cf01a-goog



More information about the U-Boot mailing list