rocky / python-uncompyle6

A cross-version Python bytecode decompiler
GNU General Public License v3.0
3.74k stars 408 forks source link

Scanner30 Class instantiate self.version as a tuple (3, 0) but expects a float #414

Closed mirkofalchetto closed 1 year ago

mirkofalchetto commented 1 year ago

Description

In version 3.8.0 when trying to decompile python 3.0 code looks like the self.version member of instantiated Scanner30 class expects in its class methods a float value instead of the provided tuple (major, minor) == (3, 0).

How to Reproduce

$ version_info = (3, 0)
$ uncompyle6.main.decompile(version_info, my_code, out_string_stream)

Output Given

      uncompyle6.main.decompile(version_info, code, string_stream)
    File "C:\my-env\lib\site-packages\uncompyle6\main.py", line 133, in decompile
      deparsed = deparse_fn(
    File "C:\my-env\lib\site-packages\uncompyle6\semantics\pysource.py", line 2576, in code_deparse
      tokens, customize = scanner.ingest(
    File "C:\my-env\lib\site-packages\uncompyle6\scanners\scanner3.py", line 292, in ingest
      jump_targets = self.find_jump_targets(show_asm)
    File "C:\my-env\lib\site-packages\uncompyle6\scanners\scanner3.py", line 583, in find_jump_targets
      self.detect_control_flow(offset, targets, i)
    File "C:\my-env\lib\site-packages\uncompyle6\scanners\scanner30.py", line 440, in detect_control_flow
      elif self.version >= 3.5:
  TypeError: '>=' not supported between instances of 'tuple' and 'float'

Expected behavior

The code should be decompiled successfully

Environment

Workarounds

None

Priority

Additional Context

mirkofalchetto commented 1 year ago

Thanks for the quick bugfix in commit d6dcaff.

probably there are still a couple of lines in the same class involving the same reported issue on lines 381 ( if self.version >= 3.5) and line 402 (if self.version == 3.0) of file scanners/scanner30.py. I'm referring to version 3.8.0.

Bests

rocky commented 1 year ago

Ok - probably fixed the commit before 9ecdf126