Whole file

pypa/distlib

The author described this change as Closes #58: Fixed incorrect handling of get_project() return value when locating non-existent distributions.. It counts as a record because the check below fails on the code as it stood at 75d9d11c2 and passes on 211e81bc1, with nothing else changed between the two runs.

Fix saved2014-12-21
Sharing licencePSF-2.0 · LICENSE.txt
Change size+4 3

What the code was meant to do, written into the code itself as a save note

Closes #58: Fixed incorrect handling of get_project() return value when locating non-existent distributions.

The change

332332 self.matcher = matcher = scheme.matcher(r.requirement)
333333 logger.debug('matcher: %s (%s)', matcher, type(matcher).__name__)
334334 versions = self.get_project(r.name)
335- if versions:
335+ if len(versions) > 2: # urls and digests keys are present
336336 # sometimes, versions are invalid
337337 slist = []
338338 vcls = matcher.version_class
885885 def _get_project(self, name):
886886 dist = self.distpath.get_distribution(name)
887887 if dist is None:
888- result = {}
888+ result = {'urls': {}, 'digests': {}}
889889 else:
890890 result = {
891891 dist.version: dist,
892- 'urls': {dist.version: set([dist.source_url])}
892+ 'urls': {dist.version: set([dist.source_url])},
893+ 'digests': {dist.version: set([None])}
893894 }
894895 return result
895896

The check that tells the two apart

failpass·tests/test_locators.py::LocatorTestCase::test_nonexistent

Check file tests/test_locators.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it75d9d11c291fa5137c0e997637e328afa26ee968
Broken version dated2014-12-17
Moduledistlib.locators
Units changedDistPathLocator, Locator
Fingerprintc4ede6c94a9330d3
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in pypa/distlib