Skip to content

Preserve embedded comment characters in parsed INI values - #85

Closed
jovial-liu wants to merge 1 commit into
pytest-dev:mainfrom
jovial-liu:fix/inline-comment-boundaries
Closed

jovial-liu wants to merge 1 commit into
pytest-dev:mainfrom
jovial-liu:fix/inline-comment-boundaries

Conversation

@jovial-liu

Copy link
Copy Markdown

IniConfig.parse() currently truncates https://example.com/#fragment to https://example.com/ and a;b to a when stripping inline comments. This also affects continuation lines.

Treat # and ; as comment prefixes only at the start of a value or after whitespace, matching configparser with inline comment prefixes enabled. Preserve embedded delimiters, including when a later whitespace-delimited comment is present. Document the rule and update the existing no-whitespace test to reflect it.

This addresses bug 2 in #83. The malformed-section-header proposal and broader compatibility policy can be considered separately. The constructor and strip_inline_comments=False retain their existing behavior.

Validation on Python 3.12:

  • Regression selection against the original parser: 15 failed, 9 passed.
  • Full test suite after the fix: 78 passed.
  • Ruff check and format check: passed.

Prepared with OpenAI Codex.

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.

2 participants