From f24ae27b27322019cf2539bdd2292ee82fe06e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Wed, 3 Jul 2024 14:05:09 +0200 Subject: [PATCH] fix #66686: don't fail for InvalidVersion, instead drop the version as-if it was never there --- salt/modules/pip.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/salt/modules/pip.py b/salt/modules/pip.py index bd56fd7a638e..484283615aef 100644 --- a/salt/modules/pip.py +++ b/salt/modules/pip.py @@ -1696,11 +1696,18 @@ def list_all_versions( for line in result["stdout"].splitlines(): match = regex.search(line) if match: - versions = [ - v for v in match.group(1).split(", ") if v and excludes.match(v) - ] - versions.sort(key=pkg_resources.parse_version) - break + versions = [] + for v in match.group(1).split(", "): + if v and excludes.match(v): + try: + pkg_resources.parse_version(v) + + except pkg_resources.extern.packaging.version.InvalidVersion as e: + logger.info(f"{e} for package {pkg}, skipping this version...") + continue + + versions.append(v) + if not versions: return None