0

When opening a tar file with the python tarfile module like

tarfile.open(path, mode='a')

i get the error

Traceback (most recent call last):
  File "/home/IPP-HGW/dboe/anaconda2/lib/python2.7/tarfile.py", line 1711, in open
    return cls.taropen(name, mode, fileobj, **kwargs)
  File "/home/IPP-HGW/dboe/anaconda2/lib/python2.7/tarfile.py", line 1721, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/home/IPP-HGW/dboe/anaconda2/lib/python2.7/tarfile.py", line 1601, in __init__
    raise ReadError(str(e))
tarfile.ReadError: empty header

I have tried to reproduce this for one day now, but can not find a general rule, when this occurs and when not. Thus it is impossible to provide a minimal example. Can anybody explain to me when this error can occur and how the header can become empty?

Many thanks in advance, Daniel

  • By "but I can not find a general rule, when this occurs and when not" do you mean that you occasionally don't get this error? – cosinepenguin Jun 14 '17 at 16:32
  • Yes, unfortunately. I do believe in the determinism of a computer though :). There must be something i do not consider, but i can not find what it is. I have the feeling, it has to do with multiple processes interfering. The strangest thing is: I have unittest running fine for me but raising this error for a colleague. – Daniel Böckenhoff Jun 15 '17 at 07:14

1 Answers1

2

This exception is raised when the buffer length is zero while parsing headers for the tarfile. It is raised for an empty archive.

Reference:

Oluwafemi Sule
  • 36,144
  • 1
  • 56
  • 81