X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/000147c007787fc26e8ccb4fb9843a6f9d80affb..03766f515b908b76a488da40fec3eeffb9369af7:/black.py diff --git a/black.py b/black.py index 151c1a6..8a70c02 100644 --- a/black.py +++ b/black.py @@ -4006,7 +4006,7 @@ def read_cache(mode: FileMode) -> Cache: with cache_file.open("rb") as fobj: try: cache: Cache = pickle.load(fobj) - except pickle.UnpicklingError: + except (pickle.UnpicklingError, ValueError): return {} return cache @@ -4041,7 +4041,7 @@ def write_cache(cache: Cache, sources: Iterable[Path], mode: FileMode) -> None: CACHE_DIR.mkdir(parents=True, exist_ok=True) new_cache = {**cache, **{src.resolve(): get_cache_info(src) for src in sources}} with tempfile.NamedTemporaryFile(dir=str(cache_file.parent), delete=False) as f: - pickle.dump(new_cache, f, protocol=pickle.HIGHEST_PROTOCOL) + pickle.dump(new_cache, f, protocol=4) os.replace(f.name, cache_file) except OSError: pass