0

What am I missing, when using the package rarfile when simply extracting a password protected rar file? The same exception is raised, when the password is byte-encoded. Right and wrong passwords raise this exception.

from rarfile import RarFile

with RarFile("testfile_rar.rar", 'r') as rf:
        rf.extractall(pwd='Pass?')

throws:

Traceback (most recent call last):
  File "/home/x/PythonProjects/rarPW/unpack_rar.py", line 4, in <module>
    rf.extractall(pwd='Pass?')
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 847, in extractall
    dst = self._extract_one(inf, path, pwd, not inf.is_dir())
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 912, in _extract_one
    return self._make_file(info, dstfn, pwd, set_attrs)
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 925, in _make_file
    with self.open(info, "r", pwd) as src:
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 783, in open
    return self._file_parser.open(inf, pwd)
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 1241, in open
    return self._open_unrar(self._rarfile, inf, pwd)
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 1294, in _open_unrar
    cmd = setup.open_cmdline(pwd, rarfile, fn)
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 3235, in open_cmdline
    cmdline = self.get_cmdline("open_cmd", pwd)
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 3247, in get_cmdline
    self.add_password_arg(cmdline, pwd)
  File "/home/x/PythonProjects/rarPW/venv/lib/python3.10/site-packages/rarfile.py", line 3265, in add_password_arg
    cmdline.extend(args)
TypeError: 'NoneType' object is not iterable
parrott
  • 368
  • 4
  • 12
  • Can you open that file in the first place? Is the password correct? – Panagiotis Kanavos Oct 13 '22 at 15:01
  • @PanagiotisKanavos I can see the contents of the rar file with files = rf.namelist() print(files) But for example rf.open(name=files[0], pwd='Pass?') raises the same error. When reading the error stack I assume there is something wrong with the password argument. – parrott Oct 13 '22 at 16:31

0 Answers0