From 63dd6387b61acdb8bb608ac3d6ead0c5803a4bea Mon Sep 17 00:00:00 2001 From: Taeknology <20297177+Taeknology@users.noreply.github.com> Date: Tue, 19 May 2026 14:53:27 +0900 Subject: [PATCH 1/2] gh-149050: Fix return type of ConfigParser.items() in documentation When called without a section argument, ConfigParser.items() delegates to dict.items() and returns a collections.abc.ItemsView, not a list. The docs previously described both overloads as returning a list. --- Doc/library/configparser.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 4d720176fcc334..3a1bd2a3b9e8b4 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -1214,7 +1214,8 @@ ConfigParser Objects .. method:: items(raw=False, vars=None) items(section, raw=False, vars=None) - When *section* is not given, return a list of *section_name*, + When *section* is not given, return a + :class:`~collections.abc.ItemsView` of *section_name*, *section_proxy* pairs, including DEFAULTSECT. Otherwise, return a list of *name*, *value* pairs for the options in the From ab94e2ba4da223537faab066b7525789e4374201 Mon Sep 17 00:00:00 2001 From: Taeknology <20297177+Taeknology@users.noreply.github.com> Date: Wed, 20 May 2026 08:34:53 +0900 Subject: [PATCH 2/2] gh-149050: Also fix the Mapping Protocol Access wording The Mapping Protocol Access bullet about parser.items() in Doc/library/configparser.rst had the same misleading 'returns a list of section_name, section_proxy pairs' phrasing as the items() method description. The no-argument call actually returns an ItemsView, while the call with a section argument returns a list. Mark up both return types explicitly so that the asymmetry between the two overloads is clear to readers. --- Doc/library/configparser.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 3a1bd2a3b9e8b4..bea042ba26de8a 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -489,12 +489,13 @@ However, there are a few differences that should be taken into account: a fallback value. Note however that the section-level ``get()`` methods are compatible both with the mapping protocol and the classic configparser API. -* ``parser.items()`` is compatible with the mapping protocol (returns a list of - *section_name*, *section_proxy* pairs including the DEFAULTSECT). However, - this method can also be invoked with arguments: ``parser.items(section, raw, - vars)``. The latter call returns a list of *option*, *value* pairs for - a specified ``section``, with all interpolations expanded (unless - ``raw=True`` is provided). +* ``parser.items()`` is compatible with the mapping protocol (when invoked + with no arguments, returns an :class:`~collections.abc.ItemsView` of + *section_name*, *section_proxy* pairs including the DEFAULTSECT). + However, this method can also be invoked with arguments: + ``parser.items(section, raw, vars)``. The latter call returns a + :class:`list` of *option*, *value* pairs for a specified ``section``, + with all interpolations expanded (unless ``raw=True`` is provided). The mapping protocol is implemented on top of the existing legacy API so that subclasses overriding the original interface still should have mappings working