From 916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c 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(+) diff --git a/Lib/gzip.py b/Lib/gzip.py index 1c196a8..578a07b 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 v0.12