Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'received:141': 0.03; 'ioerror:': 0.09; 'error:': 0.12; 'wrote:': 0.15; "'rb')": 0.16; 'ioerror.': 0.16; "isn't.": 0.16; 'it).': 0.16; 'argument': 0.16; 'operations,': 0.16; 'this:': 0.16; 'happening': 0.19; 'importing': 0.19; 'subject:problem': 0.19; 'to:2**1': 0.21; 'file,': 0.22; 'maybe': 0.22; 'header:In-Reply-To:1': 0.22; 'windows': 0.27; 'fri,': 0.28; 'guess': 0.28; 'character': 0.28; 'problem': 0.29; 'hi,': 0.30; 'print': 0.32; 'file.': 0.32; 'error': 0.33; 'does': 0.33; 'to:addr:python-list': 0.34; 'causing': 0.34; 'option.': 0.35; 'actual': 0.35; 'file': 0.36; 'charset:us-ascii': 0.36; 'idea': 0.36; 'skip:o 20': 0.36; 'error.': 0.36; 'assuming': 0.37; 'open': 0.37; 'but': 0.37; 'some': 0.37; 'getting': 0.38; 'could': 0.38; 'takes': 0.38; 'steven': 0.38; 'subject:: ': 0.38; 'data': 0.39; 'help': 0.39; 'to:addr:python.org': 0.39; 'appreciated.': 0.40; 'read,': 0.40; 'called': 0.40; 'give': 0.60; 'zip': 0.65; 'jun': 0.67; 'isolate': 0.84; 'messed': 0.84 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: unzip problem Date: Fri, 24 Jun 2011 13:23:37 -0400 In-Reply-To: <4e04ae66$0$29975$c3e8da3$5496439d@news.astraweb.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: unzip problem Thread-Index: AcwyhMCL+JW3f4eFQ8GROcijMFDBKQADn0BA References: <4e04ae66$0$29975$c3e8da3$5496439d@news.astraweb.com> From: "Ahmed, Shakir" To: "Steven D'Aprano" , X-Virus-Scanned: ClamAV 0.96.1/13237/Fri Jun 24 09:50:33 2011 X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.70 on 141.232.3.26 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308936224 news.xs4all.nl 200 [::ffff:82.94.164.166]:57425 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8389 On Fri, 24 Jun 2011 10:55:52 -0400, Ahmed, Shakir wrote: > Hi, >=20 >=20 > =20 > I am getting following error message while unziping a .zip file. Any > help or idea is highly appreciated. How do you know it is when unzipping the file? Maybe it is, or maybe it=20 isn't. The line giving the error has *two* IO operations, a read and a=20 write. Either one could give IOError. outfile.write(z.read(name)) IOError: (22, 'Invalid argument') The first thing is to isolate what is causing the error: data =3D z.read(name) outfile.write(data) Now you can be sure whether it is the read or the write which causes the=20 error. Secondly, find out what the argument is. Assuming it is the read, try=20 this: print repr(name) Can you open the zip file in Winzip or some other zip utility? Does it=20 need a password?=20 I see you do this: fh =3D open('T:\\test\\*.zip', 'rb') Do you really have a file called *.zip? I find that very hard to=20 believe... as I understand it, * is a reserved character in Windows and=20 you cannot have a file with that name. My guess is that the actual error is when you try to open the file in the=20 first place, before any unzipping takes place, but you've messed up the=20 line numbers (probably by editing the file after importing it). --=20 Steven >> The problem is happening when it is coming to write option. The * is not the real name of the zip file, I just hide the name.