Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 916fcc3

Browse files
committed
Added __del__ method to GzipFile class that will flush and close the
object, if required.
1 parent 68921df commit 916fcc3

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/gzip.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ def close(self):
251251
self.myfileobj.close()
252252
self.myfileobj = None
253253

254+
def __del__(self):
255+
if (self.myfileobj is not None or
256+
self.fileobj is not None):
257+
self.close()
258+
254259
def flush(self):
255260
self.fileobj.flush()
256261

0 commit comments

Comments
 (0)