From c4aeca7853ae3d00ac43804068e872447b0b6b79 Mon Sep 17 00:00:00 2001 From: Taeknology <20297177+Taeknology@users.noreply.github.com> Date: Wed, 20 May 2026 08:37:39 +0900 Subject: [PATCH] gh-150132: Document the no-argument overload of ConfigParser.items() The docstring of ConfigParser.items() only described the call with a section argument (returning a list of (name, value) tuples). The no-argument call delegates to MutableMapping.items() and returns an ItemsView of (section_name, section_proxy) pairs, which was previously undocumented. Reword the docstring so that both overloads are described and their return types match the actual behaviour. --- Lib/configparser.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Lib/configparser.py b/Lib/configparser.py index a53ac87276445a..606c4d7c899d67 100644 --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -885,13 +885,17 @@ def getboolean(self, section, option, *, raw=False, vars=None, raw=raw, vars=vars, fallback=fallback, **kwargs) def items(self, section=_UNSET, raw=False, vars=None): - """Return a list of (name, value) tuples for each option in a section. + """Return the items of the parser or of a section. - All % interpolations are expanded in the return values, based on the - defaults passed into the constructor, unless the optional argument - `raw` is true. Additional substitutions may be provided using the - `vars` argument, which must be a dictionary whose contents overrides - any pre-existing defaults. + When `section` is not given, return an ItemsView of + (section_name, section_proxy) pairs, including DEFAULTSECT. + + Otherwise, return a list of (name, value) tuples for each option in + the given section. All % interpolations are expanded in the return + values, based on the defaults passed into the constructor, unless the + optional argument `raw` is true. Additional substitutions may be + provided using the `vars` argument, which must be a dictionary whose + contents overrides any pre-existing defaults. The section DEFAULT is special. """