Skip to content

Prevent empty parentheses from appearing in lockfile marker#1801

Closed
oliver-charlesworth wants to merge 1 commit into
python-poetry:masterfrom
oliver-charlesworth:fix-1728
Closed

Prevent empty parentheses from appearing in lockfile marker#1801
oliver-charlesworth wants to merge 1 commit into
python-poetry:masterfrom
oliver-charlesworth:fix-1728

Conversation

@oliver-charlesworth
Copy link
Copy Markdown

@oliver-charlesworth oliver-charlesworth commented Dec 28, 2019

Fixes #1728.
Fixes #1772.

Prior to this PR, an extra dependency of the form:

foo (>=x.y.z); (some_constraint) and extra == 'bar'

would be serialised to the lockfile as:

marker = "some_constraint and ()"

Per #1728, the lockfile parser crashes on this.

This PR fixes that.

So far as I can tell this needs to be fixed on the serialisation side - empty parentheses are not permitted by the PEP 508 grammar.

The fix is implemented by updating MultiMarker.__str__ to filter out any/empty markers (which occur when with_extras=False), similarly to the existing behaviour of MarkerUnion.__str__.

I'd like to add more defensive test coverage for the various MarkerXyz classes, but I'll do that in a follow-up PR.

@finswimmer finswimmer requested a review from a team December 29, 2019 13:55
@finswimmer finswimmer added the kind/bug Something isn't working as expected label Dec 29, 2019
@finswimmer
Copy link
Copy Markdown
Member

Hey @oliver-charlesworth,

thanks a lot for your contribution 👍

It looks like this is superseded by #2361 in the meantime.

Feel free to leave a comment if you disagree.

fin swimmer

@finswimmer finswimmer closed this Sep 6, 2020
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

kind/bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid requirement, parse error at "'and ()'" Some markers are serialized into the lockfile incorrectly, resulting in crash

2 participants