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 JieGhost
Recipients JieGhost
Date 2016-07-22.15:11:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1469200266.16.0.443973453456.issue27590@psf.upfronthosting.co.za>
In-reply-to
Content
I have seen a similar ticket, however that was opened 2 years ago and has nothing more than a brief description. So I opened this new one here, hoping to get some answers.

tarfile.TarFile object is iterable and has a next() method. next() will parse the header and save parsed info. During parsing, a lot of checks are done, to make sure the header is valid. And if there is something wrong with the header, exceptions will be thrown. next() catches a lot of them but not reraise what it catches in all cases.

I have a tgz file, one of the headers is corrupted with a wrong checksum section. thus during parsing, InvalidHeaderError was thrown. next() catches that but hide it silently. From source code (https://hg.python.org/cpython/file/2.7/Lib/tarfile.py#l2335), we can see that InvalidHeaderError will ONLY be raised if it happens in the beginning of the tar file. Actually, a lot of exceptions are hidden by tarfile module. tarfile module simply thinks these exceptions mark the end of tarball.

Why does tarfile module hide so many exceptions? or in other words, why does tarfile treat these exceptions as the end marker of tarball but not errors?

Is it because of this from GNU doc:
"At the end of the archive file there are two 512-byte blocks filled with binary zeros as an end-of-file marker. A reasonable system should write such end-of-file marker at the end of an archive, but must not assume that such a block exists when reading an archive."?

Thanks!
History
Date User Action Args
2016-07-22 15:11:06JieGhostsetrecipients: + JieGhost
2016-07-22 15:11:06JieGhostsetmessageid: <1469200266.16.0.443973453456.issue27590@psf.upfronthosting.co.za>
2016-07-22 15:11:06JieGhostlinkissue27590 messages
2016-07-22 15:11:05JieGhostcreate