[Python-checkins] CVS: python/dist/src/Lib gzip.py,1.28,1.29

Martin v. L?wis loewis@users.sourceforge.net
Sun, 10 Mar 2002 22:46:54 -0800


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

Modified Files:
	gzip.py 
Log Message:
Patch #443899: Check modes on files before performing operations. 
Use IOErrors where file objects use them.


Index: gzip.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** gzip.py	13 Oct 2001 18:33:51 -0000	1.28
--- gzip.py	11 Mar 2002 06:46:52 -0000	1.29
***************
*** 62,66 ****
                                               0)
          else:
!             raise ValueError, "Mode " + mode + " not supported"
  
          self.fileobj = fileobj
--- 62,66 ----
                                               0)
          else:
!             raise IOError, "Mode " + mode + " not supported"
  
          self.fileobj = fileobj
***************
*** 134,137 ****
--- 134,141 ----
  
      def write(self,data):
+         if self.mode != WRITE:
+             import errno
+             raise IOError(errno.EBADF, "write() on read-only GzipFile object")
+         
          if self.fileobj is None:
              raise ValueError, "write() on closed GzipFile object"
***************
*** 143,146 ****
--- 147,154 ----
  
      def read(self, size=-1):
+         if self.mode != READ:
+             import errno
+             raise IOError(errno.EBADF, "write() on read-only GzipFile object")
+             
          if self.extrasize <= 0 and self.fileobj is None:
              return ''