CensoredUsername / unrpyc

A ren'py script decompiler
Other
824 stars 149 forks source link

RenPy 7.5.0 changes #146

Closed NWPlayer123 closed 4 months ago

NWPlayer123 commented 2 years ago

One of the projects I decompile regularly just upgraded from 7.4.11 to 7.5.0, and now a handful of files are throwing pickling errors (4 different variants, listed below). Tried both the latest release with the rpyc and using the command line script from master.

Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1139, in load_reduce
  File "<magic>", line 24, in __new__
FakeUnpicklingError: <class 'set'> was instantiated with unexpected arguments ([],), {}
Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1188, in load_append
AttributeError: 'RevertableList' object has no attribute 'append'
Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1195, in load_appends
AttributeError: 'RevertableList' object has no attribute 'extend'
Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1212, in load_setitems
TypeError: 'RevertableDict' object does not support item assignment
NWPlayer123 commented 2 years ago

Here's some relevant rpyc to use as a test case unrpyc-bug-report-data.zip

taharrison commented 2 years ago

Same issue. Been scratching my head over this one.

CensoredUsername commented 2 years ago

Seems like some stuff that isn't normally makes it into the .rpyc file suddenly got in there, so probably more custom AST node shenanigans. Does adding "set" to the list of classes at https://github.com/CensoredUsername/unrpyc/blob/2f9810c104d88982e7a63e9efbb52a33a9f76032/unrpyc.py#L107 fix the first one?

taharrison commented 2 years ago

I tried your suggested fix. It moves the error along a few lines. New error stacktrace:

Traceback (most recent call last):
  File "C:\dev\unrpyc-master\unrpyc.py", line 202, in worker
    tag_outside_block=args.tag_outside_block, init_offset=args.init_offset, try_harder=args.try_harder)
  File "C:\dev\unrpyc-master\unrpyc.py", line 174, in decompile_rpyc
    init_offset=init_offset)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 46, in pprint
    decompile_python=decompile_python, translator=translator).dump(ast, indent_level, init_offset, tag_outside_block)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 116, in dump
    super(Decompiler, self).dump(ast, indent_level, skip_indent_until_write=True)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 29, in dump
    self.print_nodes(ast)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 463, in print_label
    self.print_nodes(ast.block, 1)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 529, in print_if
    self.print_nodes(block, 1)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 488, in print_call
    words.append(reconstruct_arginfo(ast.arguments))
  File "C:\dev\unrpyc-master\decompiler\util.py", line 222, in reconstruct_arginfo
    if arginfo.extrapos:
AttributeError: 'ArgumentInfo' object has no attribute 'extrapos'
KateJohn commented 1 year ago

I tried your suggested fix. It moves the error along a few lines. New error stacktrace:

Traceback (most recent call last):
  File "C:\dev\unrpyc-master\unrpyc.py", line 202, in worker
    tag_outside_block=args.tag_outside_block, init_offset=args.init_offset, try_harder=args.try_harder)
  File "C:\dev\unrpyc-master\unrpyc.py", line 174, in decompile_rpyc
    init_offset=init_offset)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 46, in pprint
    decompile_python=decompile_python, translator=translator).dump(ast, indent_level, init_offset, tag_outside_block)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 116, in dump
    super(Decompiler, self).dump(ast, indent_level, skip_indent_until_write=True)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 29, in dump
    self.print_nodes(ast)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 463, in print_label
    self.print_nodes(ast.block, 1)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 529, in print_if
    self.print_nodes(block, 1)
  File "C:\dev\unrpyc-master\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "C:\dev\unrpyc-master\decompiler\__init__.py", line 488, in print_call
    words.append(reconstruct_arginfo(ast.arguments))
  File "C:\dev\unrpyc-master\decompiler\util.py", line 222, in reconstruct_arginfo
    if arginfo.extrapos:
AttributeError: 'ArgumentInfo' object has no attribute 'extrapos'

just go to decompiler/util.py and change line 222 and 225 into if hasattr(arginfo, 'extrapos') and arginfo.extrapos: if hasattr(arginfo, 'extrakw') and arginfo.extrakw:

Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1188, in load_append
AttributeError: 'RevertableList' object has no attribute 'append'
Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1195, in load_appends
AttributeError: 'RevertableList' object has no attribute 'extend'
Traceback (most recent call last):
  File "<unrpyc>", line 40, in decompile_game
  File "<unrpyc>", line 32, in decompile_rpyc
  File "<unrpyc>", line 27, in read_ast_from_file
  File "<magic>", line 143, in safe_loads
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 864, in load
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/pickle.py", line 1212, in load_setitems
TypeError: 'RevertableDict' object does not support item assignment

these can be solved by changing all renpy.python to renpy.revertable

taharrison commented 1 year ago

Can confirm the changes in this thread taken together fix the issues i was seeing.

sigio commented 1 year ago

154 pull includes these

CensoredUsername commented 1 year ago

Maybe a small update to everyone why this is taking so long: Real life has been extremely busy lately. Probably won't get to the whole python 3 move until next year.

CensoredUsername commented 4 months ago

These files seem to decompile fine (as far as I know) on dev now. Or at least, they don't crash. There's still some unimplemented 7.5 features that might show up later.

CensoredUsername commented 4 months ago

Should be fixed in the current release, please reopen if it isn't.