summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-05-08 16:59:59 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-05-08 16:59:59 (GMT)
commite298c3018cf5613aa3d8af4a5cc5652f1659f12b (patch)
treef0556d1430da984e3def128cb71f0a3435567db7 /Lib/gzip.py
parentc554505ca1318fd7aed32086ceb4b53ae767ffa3 (diff)
downloadcpython-e298c3018cf5613aa3d8af4a5cc5652f1659f12b.zip
cpython-e298c3018cf5613aa3d8af4a5cc5652f1659f12b.tar.gz
cpython-e298c3018cf5613aa3d8af4a5cc5652f1659f12b.tar.bz2
if the GzipFile constructor fails, the __del__ method is still
called. catch the resulting AttributeError and exit cleanly.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r--Lib/gzip.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 25278be..43501d4 100644
--- a/Lib/gzip.py
+++ b/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()