zrax / pycdc

C++ python bytecode disassembler and decompiler
GNU General Public License v3.0
3.17k stars 612 forks source link

Unsupported argument found for LIST_EXTEND #489

Open YWtheGod opened 3 months ago

YWtheGod commented 3 months ago
# Source Generated with Decompyle++
# File: easy.pyc (Python 3.9)

from copy import copy
from renpy.display.screen import ScreenDisplayable, get_screen_variant
from renpy.exports import loadable, pure, store
from renpy.game import context
from renpy.store import ImageReference
from saga.display.image import Image, placement
from saga.display.sdf import SDF
pure(f'''{__name__}.placement''')

def image(fn):
    if isinstance(fn, str):
        return Image(fn)

image = pure(image)

def outline(fn, **kwargs):
Unsupported opcode: DICT_MERGE
    sdf = fn.replace('.png', '.sdf')
    if not loadable(sdf):
        return fn
# WARNING: Decompyle incomplete

outline = pure(outline)

def ref(*args):
    what = context().images.apply_attributes(None, None, args)
    return ImageReference(what)

def screen(name = None, *, _scope, _sensitive, *args, **kwargs):
    scr = copy(get_screen_variant(name))
    scr.modal = 'False'
    if _sensitive:
        scr.sensitive = _sensitive
    _duplicatable = kwargs.pop('_duplicatable', False)
    if not _scope:
        pass
    scope = {
        '_args': args,
        '_kwargs': kwargs }

    def _duplicate(args = None):
        return ScreenDisplayable(scr, None, None, '', scope, **('alt', 'scope'))

    rv = _duplicate(None)
    if _duplicatable:
        rv._duplicate = _duplicate
        rv._duplicatable = True
    return rv

def stage(child = None, *, ctrl, *args, **kwargs):
Unsupported argument found for LIST_EXTEND
Error decompyling easy.pyc: std::bad_cast

easy.zip

ddouworld commented 3 months ago

Make sure you are using pycdc built with the latest source code

YWtheGod commented 3 months ago

Yes, I got the latest source code and compiled it with MSYS gcc

(base) C:\Users\ywthe\pycdc>git show -s --format=%ci HEAD
2024-05-30 14:56:07 -0700
greenozon commented 3 months ago

I see same error, it means you hit some corner case with the LIST_EXTEND opcode support which means that in the python 3.9 tasklist: https://github.com/zrax/pycdc/issues/450 is not a full checkbox, but half of it....

ddouworld commented 3 months ago

I think you're missing at least three bytecode implementations of LIST_TO_TUPLE, CALL_FUNCTION_EX_A, and DICT_MERGE_A if you want the decompile to work. If the amount of code you want to decompile is not much. You can try some AI tools to decompile it for you. Hope it can help you.

UJJWALJAAT commented 2 months ago

from copy import copy from renpy.display.screen import ScreenDisplayable, get_screen_variant from renpy.exports import loadable, pure, store from renpy.game import context from renpy.store import ImageReference from saga.display.image import Image, placement from saga.display.sdf import SDF pure(f'''{name}.placement''')

def image(fn): if isinstance(fn, str): return Image(fn)

image = pure(image)

def outline(fn, **kwargs): Unsupported opcode: DICT_MERGE sdf = fn.replace('.png', '.sdf') if not loadable(sdf): return fn

WARNING: Decompyle incomplete

outline = pure(outline)

def ref(*args): what = context().images.apply_attributes(None, None, args) return ImageReference(what)

def screen(name = None, , _scope, _sensitive, args, **kwargs): scr = copy(get_screen_variant(name)) scr.modal = 'False' if _sensitive: scr.sensitive = _sensitive _duplicatable = kwargs.pop('_duplicatable', False) if not _scope: pass scope = { '_args': args, '_kwargs': kwargs }

def _duplicate(args = None):
    return ScreenDisplayable(scr, None, None, '', scope, **('alt', 'scope'))

rv = _duplicate(None)
if _duplicatable:
    rv._duplicate = _duplicate
    rv._duplicatable = True
return rv

def stage(child = None, , ctrl, args, **kwargs): Unsupported argument found for LIST_EXTEND Error decompyling easy.pyc: std::bad_cast


[easy.zip](https://github.com/user-attachments/files/15521110/easy.zip)

from copy import copy from renpy.display.screen import ScreenDisplayable, get_screen_variant from renpy.exports import loadable, pure, store from renpy.game import context from renpy.store import ImageReference from saga.display.image import Image, placement from saga.display.sdf import SDF pure(f'{name}.placement') @pure def image(fn): if isinstance(fn, str): return Image(fn) return fn @pure def outline(fn, kwargs): sdf = fn.replace('.png', '.sdf') if not loadable(sdf): return fn return SDF(fn, sdf=sdf, kwargs) def ref(args): what = context().images.apply_attributes(None, None, args) return ImageReference(what) def screen(name, args, _scope=None, _sensitive='False', kwargs): scr = copy(get_screen_variant(name)) scr.modal = 'False' if _sensitive: scr.sensitive = _sensitive _duplicatable = kwargs.pop('_duplicatable', False) scope = _scope or {'_args': args, '_kwargs': kwargs} def _duplicate(args): return ScreenDisplayable(scr, None, None, alt='', scope=scope) rv = _duplicate(None) if _duplicatable: rv._duplicate = _duplicate rv._duplicatable = True return rv def stage(child, *args, ctrl=(), *kwargs): return store.stage(args, child=ref(child, ctrl), kwargs) @pure def unscaled(fn): return Image(fn, oversample=1)

greenozon commented 2 months ago

@UJJWALJAAT please use GH code-formatting

UJJWALJAAT commented 2 months ago

@UJJWALJAAT please use GH code-formatting

Why