Issue #20244: Fixed possible file leaks when unexpected error raised in

tarfile open functions.
This commit is contained in:
Serhiy Storchaka 2014-01-18 16:28:08 +02:00
parent c2d01423e0
commit e413cde95f
1 changed files with 6 additions and 0 deletions

View File

@ -1671,6 +1671,9 @@ class TarFile(object):
if mode == 'r':
raise ReadError("not a bzip2 file")
raise
except:
fileobj.close()
raise
t._extfileobj = False
return t
@ -1696,6 +1699,9 @@ class TarFile(object):
if mode == 'r':
raise ReadError("not an lzma file")
raise
except:
fileobj.close()
raise
t._extfileobj = False
return t