> On October 28, 2009 8:33 PM, "ryles" wrote: > <snip> > > 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' > > It should hopefully work if you use cStringIO/StringIO instead of > BytesIO. >
It does! Excellent! You've saved me the trouble of a weekend debug session. --Matt -- http://mail.python.org/mailman/listinfo/python-list