File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 2020import pip_api
2121from packaging .requirements import Requirement
2222from packaging .specifiers import SpecifierSet
23- from packaging .version import parse
23+ from packaging .version import parse , InvalidVersion
2424
2525from urllib .request import urlopen
2626from urllib .error import HTTPError
@@ -436,7 +436,14 @@ def get_latest_version(data, include_prereleases):
436436 all_versions = []
437437 count_prereleases = 0
438438 for version in data ["releases" ]:
439- v = parse (version )
439+ # NOTE: We ignore invalid version strings here so that pre-PEP-440
440+ # versions like "0.3.2d" from that past (say 2009) cannot break
441+ # the present
442+ try :
443+ v = parse (version )
444+ except InvalidVersion :
445+ print (f"Invalid version skipped (PEP 440): { version !r} " , file = sys .stderr )
446+ continue
440447 if not v .is_prerelease or include_prereleases :
441448 all_versions .append ((v , version ))
442449 else :
You can’t perform that action at this time.
0 commit comments