zipfile.py, fp.seek(-22,2) error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Waitman Gobble

    #1

    zipfile.py, fp.seek(-22,2) error

    Hello,

    I am new to Python. I am having trouble with zipfile.py.

    On a Linux machine with python 2.4.2 I have trouble opening a zipfile.
    Python is complaining about the bit where it does a seek(-22,2). Looks
    to me like zipfile.py is trying to come back 22 bytes from the end of
    file.

    # python
    Python 2.4.2 (#1, Oct 27 2005, 15:13:45)
    [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> import zipfile
    >>> zf=zipfile.ZipF ile("testdoc.od t")[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/local/lib/python2.4/zipfile.py", line 210, in __init__
    self._GetConten ts()
    File "/usr/local/lib/python2.4/zipfile.py", line 230, in _GetContents
    self._RealGetCo ntents()
    File "/usr/local/lib/python2.4/zipfile.py", line 240, in
    _RealGetContent s
    endrec = _EndRecData(fp)
    File "/usr/local/lib/python2.4/zipfile.py", line 83, in _EndRecData
    fpin.seek(-22, 2) # Assume no archive comment.
    IOError: [Errno 22] Invalid argument
    [color=blue][color=green][color=darkred]
    >>> ff=open("testdo c.odt","r")
    >>> ff.seek(-22,2)[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    IOError: [Errno 22] Invalid argument[color=blue][color=green][color=darkred]
    >>> ff.seek(0,2)
    >>> ff.seek(22,1)
    >>> ff.seek(22,2)
    >>> ff.seek(-22,2)[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    IOError: [Errno 22] Invalid argument


    on a windows machine using python 2.4.2 zipfile.py works fine.

    Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
    on win32

    IDLE 1.1.2[color=blue][color=green][color=darkred]
    >>> import zipfile
    >>> zf=zipfile.ZipF ile("testdoc.od t")
    >>> ff=open("testdo c.odt","r")
    >>> ff.seek(-22,2)
    >>> ff.seek(0,0)
    >>> ff.seek(0,2)
    >>> ff.seek(-22,2)
    >>>[/color][/color][/color]

    here is a windows machine using python 2.3.2 (cygwin)

    $ python
    Python 2.3.2 (#1, Oct 9 2003, 12:03:29)
    [GCC 3.3.1 (cygming special)] on cygwin
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> ff=open("testdo c.odt","r")
    >>> ff.seek(-22,2)
    >>> ff.seek(0,2)
    >>> ff.seek(22,2)
    >>> ff.seek(0,0)
    >>> ff.seek(-22,2)
    >>> import zipfile
    >>> zf=zipfile.ZipF ile("testdoc.od t")
    >>>[/color][/color][/color]

    seek doesn't mind going -22 from the end on a windows machine but hates
    doing it on a linux machine....

    any idears????

    Thanks and Best,

    Waitman Gobble

  • Waitman Gobble

    #2
    Re: zipfile.py, fp.seek(-22,2) error

    ok, i figured it out. the file i was trying to read on the linux
    machine was 0b. lol. i guess the "invalid argument" error was throwing
    me off.

    Comment

    Working...