From 2f0f904759b5e30c88d9a5fdcb78bb2340e981d8 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Mon, 27 Feb 2023 11:10:18 -0500 Subject: fix: Better handle failure when possible combinable file does not exist. --- coverage/data.py | 16 +++++++++++----- 1 file 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: -- cgit v1.2.1