Martin Panter added the comment:
On the other hand, you cannot use a pipe with mode="r" because that mode does
seeking; that is why I asked for more details on what you are doing:
$ cat | python3 -c 'import tarfile, sys; tarfile.open(fileobj=sys.stdin.buffer,
mode="r")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.5/tarfile.py", line 1580, in open
return func(name, filemode, fileobj, **kwargs)
File "/usr/lib/python3.5/tarfile.py", line 1610, in taropen
return cls(name, mode, fileobj, **kwargs)
File "/usr/lib/python3.5/tarfile.py", line 1467, in __init__
self.offset = self.fileobj.tell()
OSError: [Errno 29] Illegal seek
Python 3 has the io.RawIOBase class which models the low level read() system
call and does partial reads, and the io.BufferedIOBase class whose read()
method guarantees an exact read. You can often wrap a raw object with
BufferedReader to easily convert to the buffered kind.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26877>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com