Skip to content

gh-127096: Do not recreate unnamed section on every read in ConfigParser #127228

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

Merged
merged 2 commits into from
Jan 26, 2025

Conversation

PalmtopTiger
Copy link
Contributor

@PalmtopTiger PalmtopTiger commented Nov 24, 2024

The fix is based on the code from the _handle_header method. Except that I removed the part related to checking for section duplication because an unnamed section cannot be repeated within a file, and because UNNAMED_SECTION is an object and elements_added is defined as set[str].

@PalmtopTiger PalmtopTiger requested a review from jaraco as a code owner November 24, 2024 15:26
@ghost
Copy link

ghost commented Nov 24, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Nice work on adding the regression test. As I review it, I realize there are some ways that we can make this code even more safe and readable, but those concerns are outside the scope of the reported bug, so I'll deal with those separately. Just one open question.

@PalmtopTiger
Copy link
Contributor Author

There is still a problem with elements_added : set[str]. Should I change this line to elements_added : set[str | _UnnamedSection]?

@PalmtopTiger PalmtopTiger requested a review from jaraco January 19, 2025 09:16
@jaraco jaraco merged commit 914c232 into python:main Jan 26, 2025
37 checks passed
@PalmtopTiger PalmtopTiger deleted the gh-127096 branch January 27, 2025 04:42
@ZeroIntensity
Copy link
Member

@jaraco Was this supposed to get backported?

@jaraco
Copy link
Member

jaraco commented Feb 2, 2025

I hadn't put too much thought into it, but now that you suggest it, it is classified as a bug and reasonably could/should be backported. Let's do it. Just Python 3.13, right?

@jaraco jaraco added the needs backport to 3.13 bugs and security fixes label Feb 2, 2025
@miss-islington-app
Copy link

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

@miss-islington-app
Copy link

Sorry, @PalmtopTiger and @jaraco, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 914c232e9391e8e5014b089ba12c75d4a3b0cc7f 3.13

jaraco pushed a commit to jaraco/cpython that referenced this pull request Feb 2, 2025
… in ConfigParser (pythonGH-127228)

* Do not recreate unnamed section on every read in ConfigParser

* Remove duplicate section creation code
(cherry picked from commit 914c232)

Co-authored-by: Andrey Efremov <duxus@yandex.ru>
@bedevere-app
Copy link

bedevere-app bot commented Feb 2, 2025

GH-129593 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Feb 2, 2025
@AA-Turner AA-Turner added the type-bug An unexpected behavior, bug, or error label Feb 2, 2025
jaraco added a commit that referenced this pull request Feb 2, 2025
…nfigParser (GH-127228) (#129593)

* Do not recreate unnamed section on every read in ConfigParser

* Remove duplicate section creation code
(cherry picked from commit 914c232)

Co-authored-by: Andrey Efremov <duxus@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants