CensoredUsername / unrpyc

A ren'py script decompiler
Other
861 stars 157 forks source link

AtributeError in multiple files while decompiling project #84

Closed madeddy closed 4 years ago

madeddy commented 4 years ago

Possible some intended behavior/obfuscation try by the apps devs.

Outtake from original bug report #83:

!NSFW Warning! If one try's to decompile Summertimesaga v0.19.5 i got this outcome:

Decompilation of 926 files successful, but decompilation of 269 files failed

The fail's give afaik for all the 269 fails the same error:

Error while decompiling ./rpa_extract/scripts/core/user_interface/computer/app/dir.rpyc:
Traceback (most recent call last):
  File "./unrpyc-dev/unrpyc.py", line 164, in worker
    no_pyexpr=args.no_pyexpr, comparable=args.comparable, translator=translator, init_offset=args.init_offset)
  File "./unrpyc-dev/unrpyc.py", line 137, in decompile_rpyc
    translator=translator, init_offset=init_offset)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/__init__.py", line 46, in pprint
    decompile_python=decompile_python, translator=translator).dump(ast, indent_level, init_offset)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/__init__.py", line 89, in dump
    super(Decompiler, self).dump(ast, indent_level, skip_indent_until_write=True)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/util.py", line 29, in dump
    self.print_nodes(ast)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/util.py", line 120, in print_nodes
    self.print_node(node)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/__init__.py", line 106, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/__init__.py", line 590, in print_init
    self.print_nodes(ast.block)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/util.py", line 120, in print_nodes
    self.print_node(node)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/__init__.py", line 106, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/__init__.py", line 848, in print_screen
    self.printlock)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 38, in pprint
    ast, indent_level, linenumber, skip_indent_until_write)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/util.py", line 29, in dump
    self.print_nodes(ast)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/util.py", line 120, in print_nodes
    self.print_node(node)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 53, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 68, in print_screen
    tag=ast.tag)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 304, in print_keywords_and_children
    self.print_nodes(children_after_keywords, 0 if has_block else 1).py
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/util.py", line 120, in print_nodes
    self.print_node(node)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 53, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 159, in print_use
    self.print_block(ast.block)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 104, in print_block
    self.print_keywords_and_children(ast.keyword, ast.children, None)
  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 304, in print_keywords_and_children
    self.print_nodes(children_after_keywords, 0 if has_block else 1).py
AttributeError: 'NoneType' object has no attribute 'py'

Originally posted by @madeddy in https://github.com/CensoredUsername/unrpyc/issues/82#issuecomment-575968876

madeddy commented 4 years ago

Some info addition:

I compiled un.rpyc from current dev branch (used just compile.py -d) and t from the look of it the decompiling did run without errors.

However trying to run the app with the resulting *.rpy files isn't working: errors.txt I guess this is the bug from #82 though.

CensoredUsername commented 4 years ago

I looked at this closer and I think you've just made a mistake and accidentally edited sl2decompiler.py by yourself. That line is not supposed to end in .py, and it doesn't on any branches in this repo. Try redownloading unrpyc ; )

madeddy commented 4 years ago

Thanks for looking into it.

I looked at this closer and I think you've just made a mistake and accidentally edited sl2decompiler.py by yourself.

Wrong. I edited nothing. However you're right that "unrpyc" wasn't at fault. A corrupt base game was the problem.

CensoredUsername commented 4 years ago

Wrong. I edited nothing.

I understand it might've not been intentional, but the error says:

  File "/home/olli/Code/rpa_tools/unrpyc-dev/decompiler/sl2decompiler.py", line 304, in print_keywords_and_children
    self.print_nodes(children_after_keywords, 0 if has_block else 1).py

While that line in the codebase on git is actually (and has been for the last 5 years).

        self.print_nodes(children_after_keywords, 0 if has_block else 1)

Notice the lack of a trailing .py, which, since it is the file extension for python files leads me to think that a silly mistake happened somewhere, but it's definitely not a fault of unrpyc.