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

different result of '_compare_equal' prefix match with epoch #683

Closed
sify21 opened this issue Mar 23, 2023 · 0 comments · Fixed by #712
Closed

different result of '_compare_equal' prefix match with epoch #683

sify21 opened this issue Mar 23, 2023 · 0 comments · Fixed by #712

Comments

@sify21
Copy link

sify21 commented Mar 23, 2023

see the results:

图片

this happens when specifier is longer that prospective and epoch is involved. The problem originates from the function _pad_version in packaging.specifiers.

def _pad_version(left: List[str], right: List[str]) -> Tuple[List[str], List[str]]:
    left_split, right_split = [], []

    # Get the release segment of our versions
    left_split.append(list(itertools.takewhile(lambda x: x.isdigit(), left)))
    right_split.append(list(itertools.takewhile(lambda x: x.isdigit(), right)))

    # Get the rest of our versions
    left_split.append(left[len(left_split[0]) :])
    right_split.append(right[len(right_split[0]) :])

    # Insert our padding
    left_split.insert(1, ["0"] * max(0, len(right_split[0]) - len(left_split[0])))
    right_split.insert(1, ["0"] * max(0, len(left_split[0]) - len(right_split[0])))

    return (list(itertools.chain(*left_split)), list(itertools.chain(*right_split)))

This function didn't take into account the situation where epoch exists. see the testing results.

图片

SpecLad added a commit to SpecLad/packaging that referenced this issue Aug 26, 2023
`_pad_version` assumes that all components that aren't numeric are
suffixes. But that assumption breaks when epoch numbers are present,
because `_version_split` outputs a component like "2!1".

Fix the assumption by making `_version_split` separate the epoch number
into its own component. Introduce `_version_join` to correctly join
the output of `_version_split` back into a string, which is needed by
`_compare_compatible`.

Fixes pypa#683
SpecLad added a commit to SpecLad/packaging that referenced this issue Oct 1, 2023
`_pad_version` assumes that all components that aren't numeric are
suffixes. But that assumption breaks when epoch numbers are present,
because `_version_split` outputs a component like "2!1".

Fix the assumption by making `_version_split` separate the epoch number
into its own component. Introduce `_version_join` to correctly join
the output of `_version_split` back into a string, which is needed by
`_compare_compatible`.

Fixes pypa#683
SpecLad added a commit to SpecLad/packaging that referenced this issue Oct 1, 2023
`_pad_version` assumes that all components that aren't numeric are
suffixes. But that assumption breaks when epoch numbers are present,
because `_version_split` outputs a component like "2!1".

Fix the assumption by making `_version_split` separate the epoch number
into its own component. Introduce `_version_join` to correctly join
the output of `_version_split` back into a string, which is needed by
`_compare_compatible`.

Fixes pypa#683
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants