mirror of
https://github.com/python/cpython.git
synced 2025-11-02 06:31:29 +00:00
Issue #20244: Fixed possible file leaks when unexpected error raised in
tarfile open functions.
This commit is contained in:
parent
c2d01423e0
commit
e413cde95f
1 changed files with 6 additions and 0 deletions
|
|
@ -1671,6 +1671,9 @@ def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -1696,6 +1699,9 @@ def xzopen(cls, name, mode="r", fileobj=None, preset=None, **kwargs):
|
||||||
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…
Add table
Add a link
Reference in a new issue