[U-Boot] [PATCH 6/9] patman: Use items() to iterate over dictionaries in python 3.x

Paul Burton paul.burton at imgtec.com
Mon Sep 26 16:30:32 CEST 2016


In python 3.x the iteritems() method has been removed from dictionaries,
and the items() method does effectively the same thing. Convert the code
to attempt to use iteritems() to be efficient on python 2.x, but use
items() when that fails on python 3.x.

Signed-off-by: Paul Burton <paul.burton at imgtec.com>
---

 tools/patman/settings.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 3caf379..8b10630 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -94,7 +94,11 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
         if not self.has_section(project_settings):
             self.add_section(project_settings)
         project_defaults = _default_settings.get(project_name, {})
-        for setting_name, setting_value in project_defaults.iteritems():
+        try:
+            iterator = project_defaults.iteritems()
+        except:
+            iterator = project_defaults.items()
+        for setting_name, setting_value in iterator:
             self.set(project_settings, setting_name, setting_value)
 
     def get(self, section, option, *args, **kwargs):
-- 
2.10.0



More information about the U-Boot mailing list