Mercurial > public > mercurial-scm > hg
comparison mercurial/config.py @ 32318:6a773d3050c9
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.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 18 May 2017 13:38:37 -0700 |
parents | a7c687c35119 |
children | 0fa781320203 |
comparison
equal
deleted
inserted
replaced
32317:6587427b2018 | 32318:6a773d3050c9 |
---|---|
66 def source(self, section, item): | 66 def source(self, section, item): |
67 return self._source.get((section, item), "") | 67 return self._source.get((section, item), "") |
68 def sections(self): | 68 def sections(self): |
69 return sorted(self._data.keys()) | 69 return sorted(self._data.keys()) |
70 def items(self, section): | 70 def items(self, section): |
71 return self._data.get(section, {}).items() | 71 return list(self._data.get(section, {}).iteritems()) |
72 def set(self, section, item, value, source=""): | 72 def set(self, section, item, value, source=""): |
73 if pycompat.ispy3: | 73 if pycompat.ispy3: |
74 assert not isinstance(value, str), ( | 74 assert not isinstance(value, str), ( |
75 'config values may not be unicode strings on Python 3') | 75 'config values may not be unicode strings on Python 3') |
76 if section not in self: | 76 if section not in self: |