Skip to content

Commit

Permalink
Ignore invalid versions.
Browse files Browse the repository at this point in the history
Needed for `setuptools` 66 and higher when checking a package that has invalid versions on PyPI.
Fixes #52.

For example it fails on parsing `collective.recipe.template` because it has a version `1.4dev-r93307`.
See https://pypi.org/simple/collective-recipe-template/
  • Loading branch information
mauritsvanrees committed Apr 14, 2023
1 parent 14fccf9 commit 5774bd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changelog
1.7.1 (unreleased)
------------------

- Nothing changed yet.
- Ignore invalid versions.
Needed for ``setuptools`` 66 and higher when checking a package that has invalid versions on PyPI.
Fixes `issue 52 <https://github.com/plone/plone.versioncheck/issues/52>`_.
[maurits]


1.7.0 (2019-03-08)
Expand Down
8 changes: 7 additions & 1 deletion src/plone/versioncheck/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ def check(name, version, session): # noqa: C901
releases = sorted(data["releases"])
for release in releases:
# major check (overall)
rel_v = parse_version(release)
try:
rel_v = parse_version(release)
except Exception:
# likely pkg_resources.extern.packaging.version.InvalidVersion
# but really any exception can be ignored.
# See https://github.com/plone/plone.versioncheck/issues/52
continue
if rel_v <= version:
continue
rel_vtuple = mmbp_tuple(rel_v)
Expand Down

0 comments on commit 5774bd8

Please sign in to comment.