[Python-checkins] CVS: python/dist/src/Lib zipfile.py,1.10,1.11

Tim Peters tim_one@users.sourceforge.net
Wed, 04 Apr 2001 11:56:51 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv5351/python/dist/src/Lib

Modified Files:
	zipfile.py 
Log Message:
Sf bug [ #412214 ] ZipFile constructor leaves files open.
This applies the patch Fred Drake created to fix it.
I'm checking it in since I had to apply the patch anyway in order
to test its behavior on Windows.


Index: zipfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** zipfile.py	2001/03/29 04:36:08	1.10
--- zipfile.py	2001/04/04 18:56:49	1.11
***************
*** 187,193 ****
--- 187,207 ----
                  fp.seek(0, 2)
          else:
+             if not self._filePassed:
+                 self.fp.close()
+                 self.fp = None
              raise RuntimeError, 'Mode must be "r", "w" or "a"'
  
      def _GetContents(self):
+         """Read the directory, making sure we close the file if the format
+         is bad."""
+         try:
+             self._RealGetContents()
+         except BadZipfile:
+             if not self._filePassed:
+                 self.fp.close()
+                 self.fp = None
+             raise
+ 
+     def _RealGetContents(self):
          """Read in the table of contents for the ZIP file."""
          fp = self.fp