-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Conversation
There was a problem hiding this 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.
There is still a problem with |
@jaraco Was this supposed to get backported? |
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? |
Thanks @PalmtopTiger for the PR, and @jaraco for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @PalmtopTiger and @jaraco, I could not cleanly backport this to
|
… 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>
GH-129593 is a backport of this pull request to the 3.13 branch. |
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].