[issue1159051] Handle corrupted gzip files with unexpected EOF

Serhiy Storchaka report at bugs.python.org
Mon Jan 14 20:03:15 CET 2013


Serhiy Storchaka added the comment:

At the moment gzip can raise two errors on unexpected EOF: struct.error from struct.unpack() or TypeError from ord(). Both bz2 and lzma raise EOFError in such cases.

The proposed patch converts both truncated gzip errors to EOFError as for bz2 and lzma. Added similar tests for gzip, bz2 and lzma.

I doubt about backward compatibility. It's obvious that struct.error and TypeError are unintentional, and EOFError is purposed for this case. However users can catch undocumented but de facto exceptions and doesn't expect EOFError.

----------
nosy: +nadeem.vawda
stage: needs patch -> patch review
versions: +Python 3.3, Python 3.4 -Python 3.1
Added file: http://bugs.python.org/file28727/gzip_eof-3.4.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1159051>
_______________________________________


More information about the Python-bugs-list mailing list