Skip to content

Commit 64edd6a

Browse files
committed
[Patch #654421 from Matthew Mueller]
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.
1 parent 570e358 commit 64edd6a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎Lib/gzip.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ def _read_eof(self):
305305
crc32 = read32(self.fileobj)
306306
isize = U32(read32(self.fileobj)) # may exceed 2GB
307307
if U32(crc32) != U32(self.crc):
308-
raise ValueError, "CRC check failed"
308+
raise IOError, "CRC check failed"
309309
elif isize != LOWU32(self.size):
310-
raise ValueError, "Incorrect length of data produced"
310+
raise IOError, "Incorrect length of data produced"
311311

312312
def close(self):
313313
if self.mode == WRITE:

0 commit comments

Comments
 (0)