CensoredUsername / unrpyc

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

sl2decompiler.py line 342 TypeError: '>' not supported between instances of 'int' and 'NoneType' #139

Closed Bexa2 closed 2 years ago

Bexa2 commented 2 years ago

First I try with unrpyc.decompile_rpyc and if it fails with a object has no attribute xxxxxx I try with unrpyc.decompile_rpyc(encoding='utf-8') (I took care to pass encoding to read_ast_from_file and deobfuscate.read_ast and so on until it reaches safe_loads )

Failed at G:\f95zone\Cabin by the Lake
Traceback (most recent call last):
  File "G:\f95zone\normalize_paths.py", line 86, in renpy_get_name_and_version
    ret = unrpyc.decompile_rpyc(file)
  File "G:\f95zone\decompilers\rpa_decompiler\unrpyc.py", line 164, in decompile_rpyc
    decompiler.pprint(out_file, ast, decompile_python=decompile_python, printlock=printlock,
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 46, in pprint
    decompile_python=decompile_python, translator=translator).dump(ast, indent_level, init_offset, tag_outside_block) 
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 116, in dump
    super(Decompiler, self).dump(ast, indent_level, skip_indent_until_write=True)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 29, in dump
    self.print_nodes(ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 622, in print_init
    self.print_nodes(ast.block)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 937, in print_screen
    self.linenumber = sl2decompiler.pprint(self.out_file, screen, print_atl_callback,
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 38, in pprint
    return SL2Decompiler(print_atl_callback, out_file, printlock=printlock, tag_outside_block=tag_outside_block).dump(
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 29, in dump
    self.print_nodes(ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 58, in print_node
    self.advance_to_line(ast.location[1])
AttributeError: 'SLScreen' object has no attribute 'location'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\f95zone\normalize_paths.py", line 485, in <module>
    main()
  File "G:\f95zone\normalize_paths.py", line 482, in main
    fix_games(f95zone_path, type_of_game)
  File "G:\f95zone\normalize_paths.py", line 455, in fix_games
    raise e
  File "G:\f95zone\normalize_paths.py", line 452, in fix_games
    (name, version) = get_name_and_version(path)
  File "G:\f95zone\normalize_paths.py", line 92, in renpy_get_name_and_version
    raise err
  File "G:\f95zone\normalize_paths.py", line 90, in renpy_get_name_and_version
    ret = unrpyc.decompile_rpyc(file, overwrite=True, encoding="utf-8")
  File "G:\f95zone\decompilers\rpa_decompiler\unrpyc.py", line 164, in decompile_rpyc
    decompiler.pprint(out_file, ast, decompile_python=decompile_python, printlock=printlock,
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 46, in pprint
    decompile_python=decompile_python, translator=translator).dump(ast, indent_level, init_offset, tag_outside_block)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 116, in dump
    super(Decompiler, self).dump(ast, indent_level, skip_indent_until_write=True)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 29, in dump
    self.print_nodes(ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 622, in print_init
    self.print_nodes(ast.block)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 133, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\__init__.py", line 937, in print_screen
    self.linenumber = sl2decompiler.pprint(self.out_file, screen, print_atl_callback,
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 38, in pprint
    return SL2Decompiler(print_atl_callback, out_file, printlock=printlock, tag_outside_block=tag_outside_block).dump(
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 29, in dump
    self.print_nodes(ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 59, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 72, in print_screen
    self.print_keywords_and_children(ast.keyword,
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 389, in print_keywords_and_children
    self.print_nodes(children_after_keywords, 0 if has_block else 1)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\util.py", line 120, in print_nodes
    self.print_node(node)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 59, in print_node
    self.dispatch.get(type(ast), type(self).print_unknown)(self, ast)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 78, in print_if
    self._print_if(ast, "if")
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 99, in _print_if
    self.print_block(block)
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 109, in print_block
    self.print_keywords_and_children(ast.keyword, ast.children, None, atl_transform=getattr(ast, 'atl_transform', None))
  File "G:\f95zone\decompilers\rpa_decompiler\decompiler\sl2decompiler.py", line 342, in print_keywords_and_children
    if i.location[1] > last_keyword_line:
TypeError: '>' not supported between instances of 'int' and 'NoneType'

files.zip

scripts.rpyc is the file that fails scripts_from_game.rpy is the file that comes with the game scripts_from_unrpyc.rpy is the file that unrpyc tried to create from scripts.rpyc

Here's the scripts.rpy that comes with the game:


screen d2nightmap:
    add "map.png"
    imagebutton auto "glow yourroom_%s.png" focus_mask True action Jump("AlexYourBedroomN2C0")

    if alexCorruption1On:
        # scripts_from_unrpyc.rpy stops here
        imagebutton auto "glow bathroom_%s.png" focus_mask True action Jump("d2nightAlexBathroomC1")
    else:
        imagebutton auto "glow bathroom_%s.png" focus_mask True action Jump("d2nightAlexBathroomC0")
CensoredUsername commented 2 years ago

Hmm. That comparison ought to be valid in python 2. Is this by any chance from a game that is on the nightly ren'py 8.0 release channel?

CensoredUsername commented 2 years ago

Edit: decompiles fine with python 2, so another case of #92

madeddy commented 2 years ago

Hmm. That comparison ought to be valid in python 2. Is this by any chance from a game that is on the nightly ren'py 8.0 release channel?

I checked actually out of curiosity if another bright game-dev decided to use a nightly for productive work, but no. Its RenPy 7.4.8 in this game and i also got NO decompile problem with newest(1.1.8) "un.rpyc" version.

Reason must be something else like a somehow changed game or a additional file.