pip.installed: Fix traceback when _find_key doesn't return a match

This commit is contained in:
Erik Johnson 2018-12-21 10:35:09 -06:00
parent 60953b723a
commit 1410164ee9
No known key found for this signature in database
GPG Key ID: 5E5583C437808F3F

View File

@ -98,7 +98,7 @@ def _find_key(prefix, pip_list):
except StopIteration:
return None
else:
return match
return match.lower()
def _fulfills_version_spec(version, version_spec):
@ -918,11 +918,10 @@ def installed(name,
)
else:
pkg_name = _find_key(prefix, pipsearch)
if pkg_name.lower() in already_installed_packages:
continue
if pkg_name is not None \
and pkg_name not in already_installed_packages:
ver = pipsearch[pkg_name]
ret['changes']['{0}=={1}'.format(pkg_name,
ver)] = 'Installed'
ret['changes']['{0}=={1}'.format(pkg_name, ver)] = 'Installed'
# Case for packages that are an URL
else:
ret['changes']['{0}==???'.format(state_name)] = 'Installed'