Message264481
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. |
|
Date |
User |
Action |
Args |
2016-04-29 10:08:05 | martin.panter | set | recipients:
+ martin.panter, lars.gustaebel, socketpair |
2016-04-29 10:08:05 | martin.panter | set | messageid: <1461924485.13.0.563621837277.issue26877@psf.upfronthosting.co.za> |
2016-04-29 10:08:05 | martin.panter | link | issue26877 messages |
2016-04-29 10:08:04 | martin.panter | create | |
|