Skip to content

Conversation

@c10udlnk
Copy link
Contributor

When dumping Code2 object, it will dump members of co_varnames as unicode. But they also should be string entries like co_names.

image

If they're unicode, uncompyle6 will treat them as bytes, and the decompilation output will be inappropriate like (the code object corresponding to the binary in the above figure):

# python2.7 code
    def __init__(b'O_O', b'o_O', b'OwOO_O', b'O_OO_O', b'o_OO_O'):
        O_O.o_O = o_O
        O_O.OwOO_O = OwOO_O
        O_O.O_OO_O = O_OO_O
        O_O.o_OO_O = o_OO_O

It must be:

    def __init__(O_O, o_O, OwOO_O, O_OO_O, o_OO_O):
        O_O.o_O = o_O
        O_O.OwOO_O = OwOO_O
        O_O.O_OO_O = O_OO_O
        O_O.o_OO_O = o_OO_O

In my opinion, the modification should be done on the xdis side, because co_varnames and co_names are both variable names.
Thank you for such an awesome and useful tool!

fix to dump co_varnames like co_names, which prevents uncompyle6's decompilation from outputting inappropriate results when processing function parameters.
@rocky
Copy link
Owner

rocky commented Nov 29, 2024

Thanks for the kind words and thanks for the fix!

Just today realized how to make xdis awesomer and more useful. So stay tuned!

@rocky rocky merged commit be3ec97 into rocky:master Nov 29, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants