Skip to content

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

Merged
encukou merged 1 commit into
python:mainfrom
Rogdham:fix-configparser-unnamed-section-creation-mapping
Dec 19, 2025
Merged

gh-136282: Configparser: create unnamed sections via mapping protocol access#136313
encukou merged 1 commit into
python:mainfrom
Rogdham:fix-configparser-unnamed-section-creation-mapping

Conversation

@Rogdham

@Rogdham Rogdham commented Jul 5, 2025

Copy link
Copy Markdown
Contributor

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

Rogdham commented Jul 5, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

Rogdham commented Jul 5, 2025

Copy link
Copy Markdown
Contributor Author

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

@merwok

merwok commented Nov 27, 2025

Copy link
Copy Markdown
Member

I would see this as a bugfix, I can’t imagine someone using mapping protocol + unnamed section and wanting the output [<UNNAMED_SECTION>].

PR LGTM

@merwok merwok requested a review from ambv November 27, 2025 21:30
@merwok

merwok commented Dec 18, 2025

Copy link
Copy Markdown
Member

@encukou what do you think of fix vs feature classification? (with the consequence of backporting or not)

@ZeroIntensity

Copy link
Copy Markdown
Member

I don't remember my reasons for objecting to this as a bugfix -- if both of you are happy with backporting, let's do that.

@encukou encukou merged commit 4aef138 into python:main Dec 19, 2025
46 checks passed
@encukou

encukou commented Dec 19, 2025

Copy link
Copy Markdown
Member

@hugovk is the authority here.

I'm leaning towards bugfix.

@hugovk

hugovk commented Dec 19, 2025

Copy link
Copy Markdown
Member

Bugfix is fine by me.

@hugovk hugovk added the needs backport to 3.14 bugs and security fixes label Dec 19, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @Rogdham for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 19, 2025
…otocol access (pythonGH-136313)

(cherry picked from commit 4aef138)

Co-authored-by: Rogdham <3994389+Rogdham@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Dec 19, 2025

Copy link
Copy Markdown

GH-142978 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Dec 19, 2025
@Rogdham Rogdham deleted the fix-configparser-unnamed-section-creation-mapping branch December 19, 2025 17:11
cocolato pushed a commit to cocolato/cpython that referenced this pull request Dec 22, 2025
encukou pushed a commit that referenced this pull request Jan 6, 2026
…rotocol access (GH-136313) (GH-142978)

(cherry picked from commit 4aef138)

Co-authored-by: Rogdham <3994389+Rogdham@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants