Search code examples
pythondecompiling

Uncompyle2 issue: array indices must be integers


I have an issue when I am trying to decompile a .pyc file.

The traceback is the following:

Traceback (most recent call last):
  File "my.py", line 4, in <module>
    uncompyle2.uncompyle_file("/home/user/Downloads/asd.pyc", fileobj)
  File "/home/user/Desktop/uncompyle2/uncompyle2/__init__.py", line 130, in uncompyle_file
    uncompyle(version, co, outstream, showasm, showast, deob)
  File "/home/user/Desktop/uncompyle2/uncompyle2/__init__.py", line 93, in uncompyle
    tokens, customize = scanner.disassemble(co, deob=deob)
  File "/home/user/Desktop/uncompyle2/uncompyle2/Scanner.py", line 214, in disassemble
    cf = self.find_jump_targets(code)
  File "/home/user/Desktop/uncompyle2/uncompyle2/Scanner.py", line 926, in find_jump_targets
    self.detect_structure(i, op)
  File "/home/user/Desktop/uncompyle2/uncompyle2/Scanner.py", line 737, in detect_structure
    if int(self.code[jmp]) == RETURN_VALUE:
**TypeError: array indices must be integers**

Any ideas about this ?

I'm using Python 2.7.6 on a Ubuntu machine.

The command that I'm running to have this work is the following:

uncompyle2 asd.pyc

//EDIT: As far as I can tell, this happens only on a specific file(asd.py). It works on other files.

Any workaround ?


Solution

  • The .pyc file that you're trying to decompile is probably obfuscated. It's not uncompyle2s job to also deofuscate the file.

    Try something else like pyc2py. Maybe it will work.