[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2021-11-29 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11.

--
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2014-12-16 Thread liu chang

liu chang added the comment:

2232 def next(self):
2233 Return the next member of the archive as a TarInfo object, when
2234TarFile is opened for reading. Return None if there is no more
2235available.
2236 
2237 self._check(ra)
2238 if self.firstmember is not None:
2239 m = self.firstmember
2240 self.firstmember = None
2241 return m
2242 
2243 # Read the next block.
2244 self.fileobj.seek(self.offset)
2245 tarinfo = None

raise a StreamError at #2244, It should catch this Error and return None. I 
would like to post a patch to fix it.

--
nosy: +liu chang

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23056
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2014-12-16 Thread liu chang

liu chang added the comment:

a simple fix

--
keywords: +patch
Added file: http://bugs.python.org/file37465/fix-tar-23056.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23056
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2014-12-15 Thread Gregory P. Smith

New submission from Gregory P. Smith:

$ cat test.py EOF
import tarfile
import sys

with tarfile.open(sys.argv[1], mode=r|*) as f:
  while True:
info = f.next()
if not info:
  break
EOF
$ tar cf test.tar -T /dev/null
$ python2.7 test.py test.tar
Traceback (most recent call last):
  File test.py, line 6, in module
info = f.next()
  File /usr/lib/python2.7/tarfile.py, line 2319, in next
self.fileobj.seek(self.offset)
  File /usr/lib/python2.7/tarfile.py, line 555, in seek
raise StreamError(seeking backwards is not allowed)
tarfile.StreamError: seeking backwards is not allowed
$ python3.4 test.py test.tar
Traceback (most recent call last):
  File test.py, line 6, in module
info = f.next()
  File /usr/lib/python3.4/tarfile.py, line 2244, in next
self.fileobj.seek(self.offset)
  File /usr/lib/python3.4/tarfile.py, line 518, in seek
raise StreamError(seeking backwards is not allowed)
tarfile.StreamError: seeking backwards is not allowed

I have reconfirmed that the above still happens using a top of tree 2.7.9+ 
build.

--
components: Library (Lib)
messages: 232675
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: tarfile raises an exception when reading an empty tar in streaming mode
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23056
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23056] tarfile raises an exception when reading an empty tar in streaming mode

2014-12-15 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +larry, lars.gustaebel, serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23056
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com