From: Andrew M. Kuchling Date: Tue, 10 Aug 1999 13:19:30 +0000 (+0000) Subject: Added __del__ method to GzipFile class that will flush and close the X-Git-Tag: v1.6a1~1022 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c;p=thirdparty%2FPython%2Fcpython.git Added __del__ method to GzipFile class that will flush and close the object, if required. --- diff --git a/Lib/gzip.py b/Lib/gzip.py index 1c196a8ed99a..578a07bc6cc3 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -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()