From 1060813b718e60ad52508bf9df33d18e493cea56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Mic=C3=B2?= <41483803+lormico@users.noreply.github.com> Date: Sat, 6 Aug 2022 20:00:15 +0200 Subject: [PATCH] fix: don't fail if can't find a relative path to a data file on another volume on win32 (#1428) (#1430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lorenzo Micò --- coverage/data.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coverage/data.py b/coverage/data.py index f605e1644..bcbfa427c 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -132,7 +132,13 @@ def combine_parallel_data( data.update(new_data, aliases=aliases) files_combined += 1 if message: - message(f"Combined data file {os.path.relpath(f)}") + try: + message(f"Combined data file {os.path.relpath(f)}") + except ValueError: + # ValueError can be raised under Windows when os.getcwd() returns a + # folder from a different drive than the drive of f, in which case + # we print the original value of f instead of its relative path + message(f"Combined data file {f!r}") if not keep: if data._debug.should('dataio'): data._debug.write(f"Deleting combined data file {f!r}")