mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
Issue #20244: Fixed possible file leaks when unexpected error raised in
tarfile open functions.
This commit is contained in:
commit
2d1f092469
@ -1647,6 +1647,9 @@ class TarFile(object):
|
|||||||
if mode == 'r':
|
if mode == 'r':
|
||||||
raise ReadError("not a bzip2 file")
|
raise ReadError("not a bzip2 file")
|
||||||
raise
|
raise
|
||||||
|
except:
|
||||||
|
fileobj.close()
|
||||||
|
raise
|
||||||
t._extfileobj = False
|
t._extfileobj = False
|
||||||
return t
|
return t
|
||||||
|
|
||||||
@ -1672,6 +1675,9 @@ class TarFile(object):
|
|||||||
if mode == 'r':
|
if mode == 'r':
|
||||||
raise ReadError("not an lzma file")
|
raise ReadError("not an lzma file")
|
||||||
raise
|
raise
|
||||||
|
except:
|
||||||
|
fileobj.close()
|
||||||
|
raise
|
||||||
t._extfileobj = False
|
t._extfileobj = False
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user