]> granicus.if.org Git - python/commitdiff
[Patch #654421 from Matthew Mueller]
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 5 Feb 2003 21:35:07 +0000 (21:35 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 5 Feb 2003 21:35:07 +0000 (21:35 +0000)
  gzip shouldn't raise ValueError on corrupt files

  Currently the gzip module will raise a ValueError if the file was
  corrupt (bad crc or bad size).  I can't see how that applies to
  reading a corrupt file.  IOError seems better, and it's what code
  will likely be looking for.

Lib/gzip.py

index 36f9c36fd3fbeffffbb69555f4a9f0fcdd4fe20c..761d94157ba6c2ec4563fd67c1196ee8a8765544 100644 (file)
@@ -305,9 +305,9 @@ class GzipFile:
         crc32 = read32(self.fileobj)
         isize = U32(read32(self.fileobj))   # may exceed 2GB
         if U32(crc32) != U32(self.crc):
-            raise ValueError, "CRC check failed"
+            raise IOError, "CRC check failed"
         elif isize != LOWU32(self.size):
-            raise ValueError, "Incorrect length of data produced"
+            raise IOError, "Incorrect length of data produced"
 
     def close(self):
         if self.mode == WRITE: