summaryrefslogtreecommitdiff
path: root/setuptools/package_index.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-11-15 18:12:25 -0500
committerJason R. Coombs <jaraco@jaraco.com>2021-11-15 18:12:25 -0500
commit9fd1c098a664d4f2681aa1a9746757a6bce52c12 (patch)
tree6495c212622f6f70353b87e4054bb318422cf692 /setuptools/package_index.py
parentaeb641a57f19ed223d8249ae273408eda0a94762 (diff)
downloadpython-setuptools-git-9fd1c098a664d4f2681aa1a9746757a6bce52c12.tar.gz
Suppress invalid versions when parsing in package_index. They will still be allowed for now as long as DeprecationWarnings aren't treated as errors.
Diffstat (limited to 'setuptools/package_index.py')
-rw-r--r--setuptools/package_index.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index d818f44a..270e7f3c 100644
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -21,7 +21,7 @@ import setuptools
from pkg_resources import (
CHECKOUT_DIST, Distribution, BINARY_DIST, normalize_path, SOURCE_DIST,
Environment, find_distributions, safe_name, safe_version,
- to_filename, Requirement, DEVELOP_DIST, EGG_DIST,
+ to_filename, Requirement, DEVELOP_DIST, EGG_DIST, parse_version,
)
from distutils import log
from distutils.errors import DistutilsError
@@ -294,6 +294,14 @@ class PackageIndex(Environment):
self.to_scan = []
self.opener = urllib.request.urlopen
+ def add(self, dist):
+ # ignore invalid versions
+ try:
+ parse_version(dist.version)
+ except Exception:
+ return
+ return super().add(dist)
+
# FIXME: 'PackageIndex.process_url' is too complex (14)
def process_url(self, url, retrieve=False): # noqa: C901
"""Evaluate a URL as a possible download, and maybe retrieve it"""