D5649: config: reject str sections and keys on Python 3
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Jan 23 02:45:21 UTC 2019
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Otherwise we could end up with a dict having both the str
and bytes versions of a particular config item. This may cause
some tests to regress. I haven't checked. But it is better
behavior to fail fast.
We could just as easily change this to normalize the values. But
I like catching all non-compliant call sites first.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5649
AFFECTED FILES
mercurial/config.py
CHANGE DETAILS
diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -78,6 +78,10 @@
return list(self._data.get(section, {}).iteritems())
def set(self, section, item, value, source=""):
if pycompat.ispy3:
+ assert not isinstance(section, str), (
+ 'config section may not be unicode strings on Python 3')
+ assert not isinstance(item, str), (
+ 'config item may not be unicode strings on Python 3')
assert not isinstance(value, str), (
'config values may not be unicode strings on Python 3')
if section not in self:
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list