Open
Description
Feature or enhancement
Current state (3.14):
Since gh-123077 (CPython 3.14), it is possible to create an unnamed section with configparser
:
>>> cfg1 = configparser.ConfigParser(allow_unnamed_section=True)
>>> cfg1.add_section(configparser.UNNAMED_SECTION)
>>> cfg1.set(configparser.UNNAMED_SECTION, "foo", "bar")
>>> cfg1.write(fobj1)
This gives the following output file:
foo = bar
However, the mapping protocol access is not supported:
>>> cfg2 = configparser.ConfigParser(allow_unnamed_section=True)
>>> cfg2[configparser.UNNAMED_SECTION] = {"foo": "bar"}
>>> cfg2.write(fobj2)
Gives the following output file:
[<UNNAMED_SECTION>]
foo = bar
Proposal:
Implement the mapping protocol for access of the unnamed section in configparser.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response