Skip to content
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

gh-65697: Prevent configparser from writing keys it cannot properly read #129270

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

lincolnj1
Copy link

@lincolnj1 lincolnj1 commented Jan 24, 2025

Prevents configparser from writing keys containing delimiters and keys beginning with the section header pattern to a file.

Both of those scenarios create .ini files the parser cannot accurately read back. Keys beginning with the section header pattern parse back as new sections. Keys containing delimiters parse back only the first portion as a key and the remainder as a value (i.e. key: 'one=two', value:'three' writes as 'one=two=three' and parses back as key: 'one', value: 'two=three').

Unsure on whether to handle newlines in key/section/values by rejecting them when writing, rejecting them when set, or escaping them when writing.

@lincolnj1 lincolnj1 requested a review from jaraco as a code owner January 24, 2025 21:49
Copy link

cpython-cla-bot bot commented Jan 24, 2025

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jan 24, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jan 24, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@lincolnj1 lincolnj1 changed the title gh-65697 gh-65697: Prevent configparser from writing keys it cannot properly read Jan 24, 2025
@lincolnj1 lincolnj1 marked this pull request as draft January 24, 2025 22:11
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.

The implementation looks sound and the tests seem to capture the essence of the change. I like it.

The only thing I'd like to see before accepting this - is there any lingering controversy? Who might oppose this change and can we get their consent?

If we can get consent from one or two of the most vocal detractors in the linked issues, then I'd say we could proceed. Otherwise, I'd like to hear their argument for what they recommend instead. Can you help gather that consensus?

@bedevere-app
Copy link

bedevere-app bot commented Jan 26, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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