Skip to content

Commit

Permalink
Fix crashes with higher verbosity levels
Browse files Browse the repository at this point in the history
This was causing issues in running the test suite locally at higher
verbosity levels, since this block causes errors when passed a URL.
  • Loading branch information
pradyunsg authored and hrnciar committed Dec 10, 2021
1 parent 06c92a9 commit 5560d52
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from pip._internal.utils.misc import build_netloc
from pip._internal.utils.packaging import check_requires_python
from pip._internal.utils.unpacking import SUPPORTED_EXTENSIONS
from pip._internal.utils.urls import url_to_path

__all__ = ["FormatControl", "BestCandidateResult", "PackageFinder"]

Expand Down Expand Up @@ -816,7 +815,14 @@ def find_all_candidates(self, project_name: str) -> List[InstallationCandidate]:
)

if logger.isEnabledFor(logging.DEBUG) and file_candidates:
paths = [url_to_path(c.link.url) for c in file_candidates]
paths = []
for candidate in file_candidates:
assert candidate.link.url # we need to have a URL
try:
paths.append(candidate.link.file_path)
except Exception:
paths.append(candidate.link.url) # it's not a local file

logger.debug("Local files found: %s", ", ".join(paths))

# This is an intentional priority ordering
Expand Down

0 comments on commit 5560d52

Please sign in to comment.