Skip to main content


Anyone know how to read tar files from a pipe in #Python? I'm getting this error when using tarfile.open(path, mode="r|"):
  File "lib/python3.12/tarfile.py", line 690, in read
    self.fileobj.seek(offset + (self.position - start))
  File "lib/python3.12/tarfile.py", line 522, in seek
    raise StreamError("seeking backwards is not allowed")
tarfile.StreamError: seeking backwards is not allowed

reshared this

in reply to Neil E. Hodges

It looks like to write over a pipe, open the file first and pass the handle to tarfile. Might work for reading too?
https://stackoverflow.com/a/25333193
in reply to Neil E. Hodges

The solution ended up being replacing intar.extractfile(info.name) with intar.extractfile(info). 👍

reshared this