[issue26877] tarfile use wrong code when read from fileobj

2016-07-11 Thread Марк Коренберг
Марк Коренберг added the comment: http://stackoverflow.com/questions/1964806/short-read-from-filesystem-when-can-it-happen Disk-based filesystems generally use uninterruptible reads, which means that the read operation generally cannot be interrupted by a signal. Network-based filesystems some

[issue26877] tarfile use wrong code when read from fileobj

2016-05-20 Thread Марк Коренберг
Марк Коренберг added the comment: Can not reproduce in Linux. Will reopen if reproduced on MacOS X or BSD. #!/usr/bin/python3.5 import os import signal p = os.getpid() if os.fork() == 0: while True: try: os.kill(p, signal.SIGCHLD) except (ProcessLookupError, K

[issue26877] tarfile use wrong code when read from fileobj

2016-04-30 Thread Lars Gustäbel
Lars Gustäbel added the comment: Please give us some example test code that shows us what goes wrong exactly. -- ___ Python tracker ___ __

[issue26877] tarfile use wrong code when read from fileobj

2016-04-30 Thread Марк Коренберг
Марк Коренберг added the comment: Well, there are more than one workarounds for that. man read: === If a read() is interrupted by a signal after it has successfully read some data, it shall return the number of bytes read. = So, this is a way how to make "explo

[issue26877] tarfile use wrong code when read from fileobj

2016-04-29 Thread Martin Panter
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

[issue26877] tarfile use wrong code when read from fileobj

2016-04-29 Thread Марк Коренберг
Марк Коренберг added the comment: well, I don't use "r|" (but will, thanks for suggestion) In any case, assuming that read() returns exact length is wrong. There is .readexactly() (f.e. in asyncio I mean). Or, one should use simple loop to call .read() multiple times. Reading from plain file

[issue26877] tarfile use wrong code when read from fileobj

2016-04-28 Thread Martin Panter
Martin Panter added the comment: Can you give a demonstration script? I don’t see how this could be triggered. If you use a tarfile mode like "r|", it internally uses a _Stream object which has a loop to do exact reads: .

[issue26877] tarfile use wrong code when read from fileobj

2016-04-28 Thread Марк Коренберг
Марк Коренберг added the comment: The same in tarfile.copyfileobj() -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue26877] tarfile use wrong code when read from fileobj

2016-04-28 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +lars.gustaebel ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue26877] tarfile use wrong code when read from fileobj

2016-04-28 Thread Марк Коренберг
New submission from Марк Коренберг: tarfile.py: _FileInFile(): (near line 687) b = self.fileobj.read(length) if len(b) != length: raise ReadError("unexpected end of data") every read() API does not guarantee that it will read `length` bytes. So, if fileobj reads less than requestedm that