diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-11-28 23:16:40 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-11-28 23:16:40 (GMT) |
commit | d15f8bbe320811d8edaf869c91308679d246693f (patch) | |
tree | 50a5aecba5fb206b62b1b8c22d6595a1899ac63a /Lib/zipfile.py | |
parent | 97019e41102df409556a76ca347ce9cf020bf23f (diff) | |
download | cpython-d15f8bbe320811d8edaf869c91308679d246693f.zip cpython-d15f8bbe320811d8edaf869c91308679d246693f.tar.gz cpython-d15f8bbe320811d8edaf869c91308679d246693f.tar.bz2 |
SF bug 486480: zipfile __del__ is broken
ZipFile.__del__(): call ZipFile.close(), like its docstring says it does.
ZipFile.close(): allow calling more than once (as all file-like objects
in Python should support).
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index a06731e..4b59ac6 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -454,13 +454,13 @@ class ZipFile: def __del__(self): """Call the "close()" method in case the user forgot.""" - if self.fp and not self._filePassed: - self.fp.close() - self.fp = None + self.close() def close(self): """Close the file, and for mode "w" and "a" write the ending records.""" + if self.fp is None: + return if self.mode in ("w", "a"): # write ending records count = 0 pos1 = self.fp.tell() |