diff --git a/src/packaging/specifiers.py b/src/packaging/specifiers.py index 8f1e181f..ba8fe37b 100644 --- a/src/packaging/specifiers.py +++ b/src/packaging/specifiers.py @@ -399,7 +399,9 @@ def _compare_equal(self, prospective: Version, spec: str) -> bool: # We need special logic to handle prefix matching if spec.endswith(".*"): # In the case of prefix matching we want to ignore local segment. - normalized_prospective = canonicalize_version(prospective.public) + normalized_prospective = canonicalize_version( + prospective.public, strip_trailing_zero=False + ) # Get the normalized version string ignoring the trailing .* normalized_spec = canonicalize_version(spec[:-2], strip_trailing_zero=False) # Split the spec out by dots, and pretend that there is an implicit diff --git a/tests/test_specifiers.py b/tests/test_specifiers.py index 104fac9b..799f873a 100644 --- a/tests/test_specifiers.py +++ b/tests/test_specifiers.py @@ -369,6 +369,8 @@ def test_comparison_non_specifier(self): ("2!1.0", "==2!1.*"), ("2!1.0", "==2!1.0"), ("2!1.0", "!=1.0"), + ("2!1.0.0", "==2!1.0.*"), + ("2!1.0.0", "==2!1.*"), ("1.0", "!=2!1.0"), ("1.0", "<=2!0.1"), ("2!1.0", ">=2.0"),