Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some encoding warnings in Python 3.10 (PEP 597) #1614

Merged
merged 4 commits into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions piptools/cache.py
Expand Up @@ -41,10 +41,10 @@ def __str__(self) -> str:


def read_cache_file(cache_file_path: str) -> CacheDict:
with open(cache_file_path) as cache_file:
with open(cache_file_path, encoding="utf-8") as cache_file:
try:
doc = json.load(cache_file)
except json.JSONDecodeError:
except (json.JSONDecodeError, UnicodeDecodeError):
raise CorruptCacheError(cache_file_path)

# Check version and load the contents
Expand Down Expand Up @@ -108,7 +108,7 @@ def as_cache_key(self, ireq: InstallRequirement) -> CacheKey:
def write_cache(self) -> None:
"""Writes the cache to disk as JSON."""
doc = {"__format__": 1, "dependencies": self._cache}
with open(self._cache_file, "w") as f:
with open(self._cache_file, "w", encoding="utf-8") as f:
json.dump(doc, f, sort_keys=True)

def clear(self) -> None:
Expand Down