summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>1999-08-10 13:19:30 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>1999-08-10 13:19:30 (GMT)
commit916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c (patch)
tree36ad3af85a4a543541a54f6588cc161067bc0224 /Lib/gzip.py
parent68921dfa31da43cb468bbb7a99057e11b1859696 (diff)
downloadcpython-916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c.zip
cpython-916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c.tar.gz
cpython-916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c.tar.bz2
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 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()