mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +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
|
self.myfileobj = None
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if (self.myfileobj is not None or
|
try:
|
||||||
self.fileobj is not None):
|
if (self.myfileobj is None and
|
||||||
self.close()
|
self.fileobj is None):
|
||||||
|
return
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
self.close()
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
self.fileobj.flush()
|
self.fileobj.flush()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue