Skip to content

gh-136282: Configparser: create unnamed sections via mapping protocol access #136313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rogdham
Copy link
Contributor

@Rogdham Rogdham commented Jul 5, 2025

Using the mapping protocol access to create unnamed section was not supported.

With this PR you can use it:

>>> cfg = configparser.ConfigParser(allow_unnamed_section=True)
>>> cfg[configparser.UNNAMED_SECTION] = {"foo": "bar"}
>>> cfg.write(fobj)

@Rogdham
Copy link
Contributor Author

Rogdham commented Jul 5, 2025

I have opened this PR as a feature request, but if you think @jaraco that this should be a bugfix (to be included in 3.14) for gh-123049, tell me and I will open an alternative PR accordingly!

@ZeroIntensity
Copy link
Member

If we do decide to backport (which I don't think we should), we can automatically backport to 3.14 with the bot. No need for an extra PR.

@Rogdham
Copy link
Contributor Author

Rogdham commented Jul 5, 2025

we can automatically backport to 3.14 with the bot. No need for an extra PR

Yes you are right! I meant to reference gh-123049 and not gh-136282 in that case, but I guess it does not matter much at the end of the day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants