Repository navigation
fix(markers): wrap malformed quoted strings as public parse errors - #1249
Merged
henryiii merged 1 commit intoJun 19, 2026
Merged
Conversation
henryiii
reviewed
Jun 12, 2026
henryiii
left a comment
Contributor
There was a problem hiding this comment.
This does change the error type but I think it makes sense. I'll let other have a chance to look at it first, but I think I'll approve eventually if no one has objections.
henryiii
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Malformed quoted marker strings can currently leak a raw
SyntaxErrorfromast.literal_eval()instead of the public parser exceptions callers expect. For example,Marker('os_name == "C:\"')andRequirement('pkg; os_name == "C:\"')bypassInvalidMarker/InvalidRequirement.This converts literal-eval failures in the quoted-string parser path into
ParserSyntaxError, preserving the existing public wrappers and full source/caret diagnostics.This addresses one malformed-literal item from #1239.
Verification
uv run pytest tests/test_markers.py tests/test_requirements.py -quv run ruff check src/packaging/_parser.py tests/test_markers.py tests/test_requirements.pyuv run ruff format --check src/packaging/_parser.py tests/test_markers.py tests/test_requirements.pyVERDICT: approveKnown scope: this does not change marker grammar; it only maps malformed quoted literals that already reach the quoted-string parser branch onto the existing public exception contract.