From a38760d132311fff52e55f830d17861678124014 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Tue, 10 Aug 1999 13:19:30 +0000 Subject: Added __del__ method to GzipFile class that will flush and close the object, if required. --- Lib/gzip.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Lib/gzip.py') diff --git a/Lib/gzip.py b/Lib/gzip.py index 1c196a8ed9..578a07bc6c 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() -- cgit v1.2.1