En Fri, 23 Oct 2009 14:15:33 -0300, Moore, Mathew L <moor...@battelle.org> escribió:

    with io.BytesIO() as memio:
        shutil.copyfileobj(f, memio)
        zip = zipfile.ZipFile(file=memio)
        # Can't use zip.extract(), because I want to ignore paths
        # within archive.
        src = zip.open('unknowndir/src.txt')
        with open('dst.txt', mode='wb') as dst:
            shutil.copyfileobj(src, dst)


The last line throws an Error:


Traceback (most recent call last):
  File "test.py", line 25, in <module>
    shutil.copyfileobj(src, dst)
  File "C:\Python26\lib\shutil.py", line 27, in copyfileobj
    buf = fsrc.read(length)
  File "C:\Python26\lib\zipfile.py", line 594, in read
    bytes = self.fileobj.read(bytesToRead)
TypeError: integer argument expected, got 'long'

Try adding a length parameter to the copyfileobj call, so the copy is done in small enough chunks.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to