diff --git a/tarfile.py b/tarfile.py --- a/tarfile.py +++ b/tarfile.py @@ -1187,7 +1187,8 @@ if len(buf) != BLOCKSIZE: raise HeaderError("truncated header") if buf.count(NUL) == BLOCKSIZE: - raise HeaderError("empty header") + # This can happen if the tar file is empty + return chksum = nti(buf[148:156]) if chksum not in calc_chksums(buf): @@ -1233,6 +1234,9 @@ if not buf: return obj = cls.frombuf(buf) + if obj is None: + # This can happen if the tar file is empty + return obj.offset = tarfile.fileobj.tell() - BLOCKSIZE return obj._proc_member(tarfile)