config: make config.items() return a copy
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 18 May 2017 13:38:37 -0700
changeset 32358 6a773d3050c9
parent 32357 6587427b2018
child 32359 d3177aecac01
config: make config.items() return a copy config.items() was iterating over a copy of the data for the the specified section on Python 2 by using .items(). However, on Python 3, items() does not make a copy, so let's switch to explicitly making a copy to make it safe on both Python 2 and Python 3.
mercurial/config.py
--- a/mercurial/config.py	Fri May 19 03:47:43 2017 -0700
+++ b/mercurial/config.py	Thu May 18 13:38:37 2017 -0700
@@ -68,7 +68,7 @@
     def sections(self):
         return sorted(self._data.keys())
     def items(self, section):
-        return self._data.get(section, {}).items()
+        return list(self._data.get(section, {}).iteritems())
     def set(self, section, item, value, source=""):
         if pycompat.ispy3:
             assert not isinstance(value, str), (