Skip to content

Commit

Permalink
catch an exception when parsing metadata which only occurs in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Sep 3, 2023
1 parent 1b94a91 commit 07a0d2f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False

import email.errors
import json
import mimetypes
import os
Expand Down Expand Up @@ -455,11 +456,19 @@ def _cache_metadata(
) -> None:
if self._metadata_cache is None:
return
with self._metadata_cache.cache_path(link).open("w") as f:
cacheable_dist = CacheableDist.from_dist(link, metadata_dist)
args = cacheable_dist.to_json()
logger.debug("caching metadata for link %s at %s", link.url, f.name)
json.dump(args, f)
try:
with self._metadata_cache.cache_path(link).open("w") as f:
cacheable_dist = CacheableDist.from_dist(link, metadata_dist)
args = cacheable_dist.to_json()
logger.debug("caching metadata for link %s at %s", link.url, f.name)
json.dump(args, f)
except email.errors.HeaderParseError as e:
logger.debug(
"could not cache metadata for dist %s from %s: %s",
metadata_dist,
link,
e,
)

def _fetch_metadata_using_link_data_attr(
self,
Expand Down

0 comments on commit 07a0d2f

Please sign in to comment.