mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
if the GzipFile constructor fails, the __del__ method is still
called. catch the resulting AttributeError and exit cleanly.
This commit is contained in:
parent
c554505ca1
commit
e298c3018c
1 changed files with 7 additions and 3 deletions
10
Lib/gzip.py
10
Lib/gzip.py
|
@ -253,9 +253,13 @@ class GzipFile:
|
|||
self.myfileobj = None
|
||||
|
||||
def __del__(self):
|
||||
if (self.myfileobj is not None or
|
||||
self.fileobj is not None):
|
||||
self.close()
|
||||
try:
|
||||
if (self.myfileobj is None and
|
||||
self.fileobj is None):
|
||||
return
|
||||
except AttributeError:
|
||||
return
|
||||
self.close()
|
||||
|
||||
def flush(self):
|
||||
self.fileobj.flush()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue