tar.extractall() does not recognize unexpected EOF
I wrote a work around. It works with my tar files. I guess it supports not all types of objects which can be stored in a tar file.
# -*- coding: utf-8 -*-from __future__ import absolute_import, division, unicode_literals, print_functionimport osimport tarfileclass TarfileWhichRaisesOnEOF(tarfile.TarFile): def extractall(self, path=".", members=None): super(TarfileWhichRaisesOnEOF, self).extractall(path, members) if members is None: members = self for tarinfo in members: if not tarinfo.isfile(): continue file=os.path.join(path, tarinfo.name) size_real=os.path.getsize(file) if size_real!=tarinfo.size: raise tarfile.ExtractError('Extracting %s: Size does not match. According to tarinfo %s and on disk %s' % ( tarinfo, tarinfo.size, size_real))