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.4
process
Status: open Resolution:
Dependencies: 6584 Superseder:
Assigned To: Nosy List: ezio.melotti, maker, r.david.murray, serhiy.storchaka, srid, vstinner
Priority: normal Keywords: easy

Created on 2009-08-07 21:11 by srid, last changed 2012-12-03 16:02 by serhiy.storchaka.

Messages (5)
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 (vstinner) * (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?
msg176848 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-03 16:02
See also related issue4844 and issue14315 for zipfile.
History
Date User Action Args
2012-12-03 16:02:44serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg176848
versions: + Python 3.4, - Python 3.3
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.murraysetpriority: normal

dependencies: + gzip module has no custom exception
type: behavior -> enhancement
versions: + Python 2.7, Python 3.2, - Python 2.6
keywords: + easy
nosy: + r.david.murray

messages: + msg91578
stage: test needed
2009-08-14 22:51:56vstinnersetnosy: + vstinner
messages: + msg91577
2009-08-07 21:11:15sridcreate