summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLib/tarfile.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index d914485c66..79566e7e97 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1647,6 +1647,9 @@ class TarFile(object):
if mode == 'r':
raise ReadError("not a bzip2 file")
raise
+ except:
+ fileobj.close()
+ raise
t._extfileobj = False
return t
@@ -1672,6 +1675,9 @@ class TarFile(object):
if mode == 'r':
raise ReadError("not an lzma file")
raise
+ except:
+ fileobj.close()
+ raise
t._extfileobj = False
return t