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.
Projectpypa/distlib
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
| 332 | 332 | self.matcher = matcher = scheme.matcher(r.requirement) | |
| 333 | 333 | logger.debug('matcher: %s (%s)', matcher, type(matcher).__name__) | |
| 334 | 334 | versions = self.get_project(r.name) | |
| 335 | - | if versions: | |
| 335 | + | if len(versions) > 2: # urls and digests keys are present | |
| 336 | 336 | # sometimes, versions are invalid | |
| 337 | 337 | slist = [] | |
| 338 | 338 | vcls = matcher.version_class | |
| ⋯ | |||
| 885 | 885 | def _get_project(self, name): | |
| 886 | 886 | dist = self.distpath.get_distribution(name) | |
| 887 | 887 | if dist is None: | |
| 888 | - | result = {} | |
| 888 | + | result = {'urls': {}, 'digests': {}} | |
| 889 | 889 | else: | |
| 890 | 890 | result = { | |
| 891 | 891 | 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])} | |
| 893 | 894 | } | |
| 894 | 895 | return result | |
| 895 | 896 | ||
The check that tells the two apart
fail→pass·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.