From patchwork Thu May 18 20:51:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: config: make config.items() return a copy From: via Mercurial-devel X-Patchwork-Id: 20689 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Thu, 18 May 2017 13:51:17 -0700 # HG changeset patch # User Martin von Zweigbergk # Date 1495139917 25200 # Thu May 18 13:38:37 2017 -0700 # Node ID d4f7ddd317c69bf100ed43d312ceace9f28316f1 # Parent 0d6b3572ad924103128bb9cd296000fc6fd821ef 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. diff --git a/mercurial/config.py b/mercurial/config.py --- a/mercurial/config.py +++ b/mercurial/config.py @@ -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), (