Skip to content

Commit 7fc553a

Browse files
committed
fix: preserve tar member lookup context
1 parent fb69a24 commit 7fc553a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

biothings/utils/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ def anyfile(infile, mode="r"):
219219
tar_file = tarfile.open(infile, mode) # pylint: disable=consider-using-with
220220
try:
221221
extracted = tar_file.extractfile(rawfile)
222-
except KeyError:
222+
except KeyError as exc:
223223
# provided rawfile does not appear in the tarball
224224
tar_file.close()
225-
raise FileNotFoundError("target member does not contain the provided tar file.")
225+
raise FileNotFoundError("target member does not contain the provided tar file.") from exc
226226

227227
# extracted member is not a regular file or link
228228
if extracted is None:

0 commit comments

Comments
 (0)