diff options
author | Andrew M. Kuchling <amk@amk.ca> | 1999-08-10 13:19:30 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 1999-08-10 13:19:30 (GMT) |
commit | 916fcc3b1833119c24e6cbd2e3ccefee2f72bf6c (patch) | |
tree | 36ad3af85a4a543541a54f6588cc161067bc0224 /Lib/gzip.py | |
parent | 68921dfa31da43cb468bbb7a99057e11b1859696 (diff) | |
download | cpython-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.py | 5 |
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() |