[PATCH] config: make config.items() return a copy
Jun Wu
quark at fb.com
Thu May 18 17:19:40 EDT 2017
Looks good to me.
Excerpts from Martin von Zweigbergk's message of 2017-05-18 13:51:17 -0700:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # 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), (
More information about the Mercurial-devel
mailing list