'Python 2.7.12 zipfile password exception

I have a question to the zipfile library in python 2.7.12. It seems that if I try to extract a .zip that is password protected, an exception is thrown.

I am able to extract a zipdirectory without password protection with python, and I have confirmed that i am able to extract it on my linux system without python and the right passphrase.

I will now post the unzipping process on my local console:

>>> import zipfile
>>> z = zipfile.ZipFile("folder.zip","r")
>>> z.extractall(pwd="taddel")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/zipfile.py", line 1040, in extractall
    self.extract(zipinfo, path, pwd)
  File "/usr/lib/python2.7/zipfile.py", line 1028, in extract
    return self._extract_member(member, path, pwd)
  File "/usr/lib/python2.7/zipfile.py", line 1082, in _extract_member
    with self.open(member, pwd=pwd) as source, \ 
  File "/usr/lib/python2.7/zipfile.py", line 1007, in open
    raise RuntimeError("Bad password for file", name)
RuntimeError: ('Bad password for file', <zipfile.ZipInfo object at 0x7f31cd1c3370>)
>>>

I could give you the script I was developing at, but broken down it does nothing more than trying to dictonary-force the password and split everything into nice threads. I know this IS the right password for this file, cause i made it myself. I also already tried to .strip("\n") and to convert to ("utf-8").

I also know I do not have to specify a folder in which everything is extracted into, cause with a not password protected zip-archieve this code works perfectly fine.

How can I fix this? Or even, are there updated python libs available if the standart ones are not working?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source