commit | 916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c | [log] [tgz] |
---|---|---|
author | Andrew M. Kuchling <amk@amk.ca> | Tue Aug 10 13:19:30 1999 +0000 |
committer | Andrew M. Kuchling <amk@amk.ca> | Tue Aug 10 13:19:30 1999 +0000 |
tree | 36ad3af85a4a543541a54f6588cc161067bc0224 | |
parent | 68921dfa31da43cb468bbb7a99057e11b1859696 [diff] |
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 1c196a8..578a07b 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py
@@ -251,6 +251,11 @@ 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()