summaryrefslogtreecommitdiff
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>1999-08-10 13:19:30 +0000
committerAndrew M. Kuchling <amk@amk.ca>1999-08-10 13:19:30 +0000
commita38760d132311fff52e55f830d17861678124014 (patch)
treeb98c226edd935e2339b665e8ad0fafa5927bfab7 /Lib/gzip.py
parentc67346420e1d8f80cdc329af45712f3feb8b6a18 (diff)
downloadcpython-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.py5
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()