if the GzipFile constructor fails, the __del__ method is still
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 8 May 2000 16:59:59 +0000 (16:59 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 8 May 2000 16:59:59 +0000 (16:59 +0000)
called.  catch the resulting AttributeError and exit cleanly.

Lib/gzip.py

index 25278bef3b7c1c4234ef6b863ba06ddb860ecacd..43501d40a7a8ff65670e64da5b534008140681a2 100644 (file)
@@ -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()