diff options
author | Brad Smith <bradster@infinitewarp.com> | 2023-02-27 11:10:18 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-03-16 06:41:14 -0400 |
commit | 2f0f904759b5e30c88d9a5fdcb78bb2340e981d8 (patch) | |
tree | b90f973ab65fc2864e5f203ca51e89b4f2ae1044 /coverage/data.py | |
parent | 86deccd8e643f7f7ddf60ecd8311e71ecb0d4e09 (diff) | |
download | python-coveragepy-git-2f0f904759b5e30c88d9a5fdcb78bb2340e981d8.tar.gz |
fix: Better handle failure when possible combinable file does not exist.pr/1567
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/coverage/data.py b/coverage/data.py index c737d593..abe6b510 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -145,11 +145,17 @@ def combine_parallel_data( # we print the original value of f instead of its relative path rel_file_name = f - with open(f, "rb") as fobj: - hasher = hashlib.new("sha3_256") - hasher.update(fobj.read()) - sha = hasher.digest() - combine_this_one = sha not in file_hashes + try: + with open(f, "rb") as fobj: + hasher = hashlib.new("sha3_256") + hasher.update(fobj.read()) + sha = hasher.digest() + combine_this_one = sha not in file_hashes + except FileNotFoundError as exc: + if data._warn: + data._warn(str(exc)) + if message: + message(f"Couldn't combine data file {rel_file_name}: {exc}") delete_this_one = not keep if combine_this_one: |