config: reject str sections and keys on Python 3
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 22 Jan 2019 17:08:53 -0800
changeset 41317 4ad002b2584d
parent 41316 8df3471931cc
child 41318 6e54caaed08d
config: reject str sections and keys on Python 3 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. Differential Revision: https://phab.mercurial-scm.org/D5649
mercurial/config.py
--- a/mercurial/config.py	Tue Jan 22 17:02:40 2019 -0800
+++ b/mercurial/config.py	Tue Jan 22 17:08:53 2019 -0800
@@ -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: