classification
Title: TarFile.getmembers fails at struct.unpack: unpack requires a string argument of length 4
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: gzip module has no custom exception
View: 6584
Superseder:
Assigned To: Nosy List: ezio.melotti, haypo, maker, r.david.murray, srid
Priority: normal Keywords: easy

Created on 2009-08-07 21:11 by srid, last changed 2011-08-24 07:13 by maker.

Messages (4)
msg91412 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-08-07 21:11
Perhaps this must be wrapped under a programmer-expected custom 
exception class (TarError maybe)

    for tarinfo in tarfileobj.getmembers():
  File "/home/apy/ActivePython-2.6/lib/python2.6/tarfile.py", line 
1791, in getmembers
    self._load()        # all members, we first have to
  File "/home/apy/ActivePython-2.6/lib/python2.6/tarfile.py", line 
2352, in _load
    tarinfo = self.next()
  File "/home/apy/ActivePython-2.6/lib/python2.6/tarfile.py", line 
2307, in next
    self.fileobj.seek(self.offset)
  File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 382, in 
seek
    self.read(1024)
  File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 219, in 
read
    self._read(readsize)
  File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 267, in 
_read
    self._read_eof()
  File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 300, in 
_read_eof
    crc32 = read32(self.fileobj)
  File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 24, in 
read32
    return struct.unpack("<I", input.read(4))[0]
error: unpack requires a string argument of length 4
msg91577 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2009-08-14 22:51
First, gzip should use its own errors: this issue depends on #6584.
msg91578 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-08-14 22:59
Since 6584 is deemed (correctly, IMO) a feature request, this one must
be as well.
msg142521 - (view) Author: Michele OrrĂ¹ (maker) Date: 2011-08-20 10:37
Would it be better to use TarError as Sridhar suggested, or create a new class BadTarfile(TarError, IOError), following the convention used for gzip and zipfile?
History
Date User Action Args
2011-08-24 07:13:11makersetnosy: + ezio.melotti
2011-08-20 10:37:00makersetnosy: + maker
messages: + msg142521
2011-07-22 19:40:04terry.reedysetversions: + Python 3.3, - Python 2.7, Python 3.2
2009-08-14 22:59:40r.david.murrayset
nosy: + r.david.murray
versions: + Python 2.7, Python 3.2, - Python 2.6
messages: + msg91578
priority: normal
dependencies: + gzip module has no custom exception
keywords: + easy
type: behavior -> enhancement
stage: test needed
2009-08-14 22:51:56hayposetnosy: + haypo
messages: + msg91577
2009-08-07 21:11:15sridcreate