zrax / pycdc

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

Support Python 3.12 decompilation #453

Open zrax opened 9 months ago

zrax commented 9 months ago

Tasks

Seneral commented 7 months ago

Added support for the following POP_JUMP_IF_NOT_NONE POP_JUMP_IF_NONE CALL_INTRINSIC_1 (only INTRINSIC_IMPORT_STAR)

patch.txt

EDIT: Fixed logging for unsupported intrinsic_1

I have no idea how to implement the other intrinsics, I found no obvious mapping to prior opcodes like with IMPORT_STAR and since I have no code to test it against either, this is all I can do rn. The script I wanted decompiled is successfully decompiled now, so thanks a lot for this project!

Seneral commented 6 months ago

Warning: In my test file, it seems it's inverted - POP_JUMP_IF_NOT_NONE_A needed to be come if xxx is None: for the decompiled behaviour to match the original. No occurences of POP_JUMP_IF_NONE_A to double-check sadly. Not sure if this is a general error, cpython seems to treat POP_JUMP_IF_NOT_NONE_A as expected, and the opcodes also match the ones found here. This will need proper verification.

rockingdice commented 4 months ago

pycdc crashes for some pyc files when parsing JUMP_BACKWARD_A(140) in python 3.11, could you examine what the error is?

greenozon commented 4 months ago

JUMP_BACKWARD is still not in main branch, you could try to play with this PR: https://github.com/zrax/pycdc/pull/472

rockingdice commented 4 months ago

JUMP_BACKWARD is still not in main branch, you could try to play with this PR: #472

Thanks for the pr!

DEMON1A commented 4 months ago

Anything new about LOAD_FAST_AND_CLEAR?

jsrcode commented 20 hours ago

JUMP_BACKWARD

JUMP_BACKWARD_A与JUMP_BACKWARD是否有区别

jsrcode commented 20 hours ago

POP_JUMP_IF_NONE

合并后依旧报错Unsupported opcode: POP_JUMP_IF_NONE (239)