if the GzipFile constructor fails, the __del__ method is still
called. catch the resulting AttributeError and exit cleanly.
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 @@
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()