According to `ConfigParser.items` docs: > When section is not given, return a list of section_name, section_proxy pairs, including DEFAULTSECT. > Otherwise, return a list of name, value pairs for the options in the given section. Optional arguments have the same meaning as for the get() method. https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.items However due to `d = self._defaults.copy()` on line 843 of configparser.py the default section is always included, even when a section argument is specified.
The fix for the actual issue is quite trivial (and should fix bpo-33251 at the same time). However `ExtendedInterpolation::_interpolate_some` relies on the options from the default section always being returned. Not only does this make the fix more complicated, it also makes me worry that aligning behaviour to match the documentation (which I personally feel makes more sense) will breake backwards compatibility.
See line 379 in configparser.py. BasicInterpolation is also assumed to work for values from the default section. This is why the default section exists in the first place. More importantly, as you're pointing out, even though this is an omission of the documentation, existing code in the wild probably assumes that `items()` include pairs from the default section. This is how ConfigParser worked in Python 2. If you don't want this behavior, use cfgparser[section].items() instead which does what you want. If you think this is helpful, go ahead and extend the documentation of ConfigParser.items() to point out this weirdness. But we won't be going forward with PR 6567.