]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added __del__ method to GzipFile class that will flush and close the
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 10 Aug 1999 13:19:30 +0000 (13:19 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 10 Aug 1999 13:19:30 +0000 (13:19 +0000)
object, if required.

Lib/gzip.py

index 1c196a8ed99a0da475150f3e9ca0c66b08656053..578a07bc6cc308d4637d851c531b3bc209bbe8e9 100644 (file)
@@ -251,6 +251,11 @@ class GzipFile:
             self.myfileobj.close()
             self.myfileobj = None
 
+    def __del__(self):
+        if (self.myfileobj is not None or
+            self.fileobj is not None):
+            self.close()
+        
     def flush(self):
         self.fileobj.flush()