miurahr / py7zr

7zip in python3 with ZStandard, PPMd, LZMA2, LZMA1, Delta, BCJ, BZip2, and Deflate compressions, and AES encryption.

Home Page:https://pypi.org/project/py7zr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed raising UnsupportedCompressionMethodError as an argument error when trying to extract an unsupported archive in thread extraction mode

dio-gh opened this issue · comments

Bug Description:

Extraction fails midway, despite the same archive extracting fine with regular 7-Zip. The exact error is:

TypeError: UnsupportedCompressionMethodError.__init__() missing 1 required positional argument: 'message'

To Reproduce:

Simply try extracting the file with py7zr x <filename>, or via extractall().

Expected behavior:

Should complete proper.

Environment:

  • OS: Windows 8.1 Pro
  • Python version: 3.10.4
  • py7zr version: latest from pip (0.18.3)

Test Data:

Uploading .7z files to GitHub is not supported, but you can retrieve the file directly from here. It's the archive of the latest build of the emulator called RPCS3.

Additional context:

The full traceback...
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\Scripts\py7zr.exe\__main__.py", line 7, in <module>
  File "C:\Python310\lib\site-packages\py7zr\__main__.py", line 25, in main
    return cli.Cli().run()
  File "C:\Python310\lib\site-packages\py7zr\cli.py", line 99, in run
    return args.func(args)
  File "C:\Python310\lib\site-packages\py7zr\cli.py", line 358, in run_extract
    a.extractall(callback=cb)
  File "C:\Python310\lib\site-packages\py7zr\py7zr.py", line 975, in extractall
    self._extract(path=path, return_dict=False, callback=callback)
  File "C:\Python310\lib\site-packages\py7zr\py7zr.py", line 633, in _extract
    self.worker.extract(
  File "C:\Python310\lib\site-packages\py7zr\py7zr.py", line 1254, in extract
    raise exc_type(exc_val).with_traceback(exc_tb)
TypeError: UnsupportedCompressionMethodError.__init__() missing 1 required positional argument: 'message'
What I'm trying to accomplish...

I'm writing a background updater for the aforementioned emulator, and I'm trying to get rid of the subshelling to 7-Zip, because it's unsafe and not nice. And because I hope to save a few more lines of code... :))

A file reported is not supported because it compressed with LZMA2+BCJ2
Duplicated issue with #408, #414

A type error is happened because

When extraction thread raise exception, it catch and push into a queue
at py7zr.py:1281

                exc_tuple = sys.exc_info()
                exc_q.put(exc_tuple)

then dequeue it at py7zr:1253 and try raise it

                        (exc_type, exc_val, exc_tb) = exc_q.get()
                        raise exc_type(exc_val).with_traceback(exc_tb)

There may be a code problem.

A fix for TypeError is merged into master.

A file reported is not supported because it compressed with LZMA2+BCJ2

Ah sorry, I assumed full feature parity with 7-Zip / 7z archives. I'm not that familiar with the intricacies of the format, so those tickets didn't stand out to me.

Thanks for the quick response. Closing.

@dio-gh Thanks for feedback.
Your report pull my head up to investigate TypeError and find a bug on error handler.

Python core library lzma supports LZMA2+BCJ and LZMA+BCJ but not LZMA2+BCJ2 because dependency library liblzma don't support it. py7zr uses python core library or 3rd party libraries for algorithms.