title: Decompress zip file with password fails - bug in Python?
body: <p>I get a strange error in python. When I try to extract a password protected file using the zip module, I get an exception when trying to set "oy" as password. Everything else seems to work. A bug in ZipFile module?</p>
  
  <pre><code>import zipfile    
  zip = zipfile.ZipFile("file.zip", "r")
  zip.setpassword("oy".encode('utf-8'))
  zip.extractall() #Above password "oy" generates the error here
  zip.close()
  </code></pre>
  
  <p>This is the exception I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "unzip.py", line 4, in &lt;module&gt;
      zip.extractall()
    File "C:\Program Files\Python32\lib\zipfile.py", line 1002, in extrac
  l
      self.extract(zipinfo, path, pwd)
    File "C:\Program Files\Python32\lib\zipfile.py", line 990, in extract
      return self._extract_member(member, path, pwd)
    File "C:\Program Files\Python32\lib\zipfile.py", line 1035, in _extra
  member
      shutil.copyfileobj(source, target)
    File "C:\Program Files\Python32\lib\shutil.py", line 65, in copyfileo
      buf = fsrc.read(length)
    File "C:\Program Files\Python32\lib\zipfile.py", line 581, in read
      data = self.read1(n - len(buf))
    File "C:\Program Files\Python32\lib\zipfile.py", line 633, in read1
      max(n - len_readbuffer, self.MIN_READ_SIZE)
  zlib.error: Error -3 while decompressing: invalid block type
  </code></pre>
  
  <p>If I use UTF-16 as encoding I get this error: </p>
  
  <pre><code>zlib.error: Error -3 while decompressing: invalid distance too far back
  </code></pre>
  
  <p><strong>EDIT</strong>
  I have now tested on a virtual Linux machine with following stuff:</p>
  
  <ul>
  <li>Python version: 2.6.5 </li>
  <li>I created a password protected zip file with <code>zip -e file.zip
  hello.txt</code></li>
  </ul>
  
  <p>Now it seems the problem is something else. Now I can extract the zip file even if the password is wrong!</p>
  
  <pre><code>try:
      zip.setpassword("ks")  # "ks" is wrong password but it still extracts the zip
      zip.extractall()
  except RuntimeException:
      print "wrong!"
  </code></pre>
  
  <p>Sometimes I can extract the zip file with an incorrect password. The file (inside the zip file) is then extracted but when I try to open it the information seems to be corrupted/decrypted. </p>