This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Fabio.Erculiani
Recipients Fabio.Erculiani
Date 2013-11-30.10:16:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385806619.04.0.329117891617.issue19839@psf.upfronthosting.co.za>
In-reply-to
Content
In Sabayon Linux and Gentoo Linux, distro package metadata is appended at the end of bz2 files. Python 2.7, 3.1, 3.2 bz2 modules were handling the following attached file just fine, trailing garbage was simply ignored like the bunzip2 utility does.

example test code:
f = bz2.BZ2File(path, mode="rb")
data = f.read(1024)
while data:
    data = f.read(1024)
f.close()

The following code doesn't work with Python 3.3.3 anymore, at some point I receive the following exception (that comes from the bz2 module C code):

  File "/usr/lib64/python3.3/bz2.py", line 278, in read
    return self._read_block(size)
  File "/usr/lib64/python3.3/bz2.py", line 239, in _read_block
    while n > 0 and self._fill_buffer():
  File "/usr/lib64/python3.3/bz2.py", line 203, in _fill_buffer
    self._buffer = self._decompressor.decompress(rawblock)
OSError: Invalid data stream

Please restore the compatibility with bz2 files with trailing garbage after EOF.
History
Date User Action Args
2013-11-30 10:16:59Fabio.Erculianisetrecipients: + Fabio.Erculiani
2013-11-30 10:16:59Fabio.Erculianisetmessageid: <1385806619.04.0.329117891617.issue19839@psf.upfronthosting.co.za>
2013-11-30 10:16:59Fabio.Erculianilinkissue19839 messages
2013-11-30 10:16:58Fabio.Erculianicreate