This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients lars.gustaebel, martin.panter, socketpair
Date 2016-04-29.10:08:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461924485.13.0.563621837277.issue26877@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-04-29 10:08:05martin.pantersetrecipients: + martin.panter, lars.gustaebel, socketpair
2016-04-29 10:08:05martin.pantersetmessageid: <1461924485.13.0.563621837277.issue26877@psf.upfronthosting.co.za>
2016-04-29 10:08:05martin.panterlinkissue26877 messages
2016-04-29 10:08:04martin.pantercreate