diff options
author | Andrew M. Kuchling <amk@amk.ca> | 1999-08-10 13:19:30 +0000 |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 1999-08-10 13:19:30 +0000 |
commit | a38760d132311fff52e55f830d17861678124014 (patch) | |
tree | b98c226edd935e2339b665e8ad0fafa5927bfab7 /Lib/gzip.py | |
parent | c67346420e1d8f80cdc329af45712f3feb8b6a18 (diff) | |
download | cpython-a38760d132311fff52e55f830d17861678124014.tar.gz |
Added __del__ method to GzipFile class that will flush and close the
object, if required.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 5 |
1 files changed, 5 insertions, 0 deletions
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() |