Closed ZetaTwo closed 2 years ago
I'd be willing to implement this and provide a PR for this but I would like your opinion if it should be a warning or renaming the variables or maybe even some command line option to choose between the two.
Sure, If you are willing to do this, I'm okay with adding this feature. However, the place where this would be done is in the cross-version disassembly xdis.
Then an option would be added here to pass over the setting to the xdis disassembler.
Probably an issue there should be opened as well.
Ok great. I'll open another issue and continue the discussion there. Thank you.
Description
uncompyle6 blindly trists the names of the variables in the code object even if they are not valid Python symbol names. This can lead to incorrect decompilation output
How to Reproduce
If we compile the following Python code into bytecode:
and manually rename the variable "EVIL" to "y = 'Hello' #", the output when running will still be "Hello World" but if we decompile it, the output from uncompyle will be:
and running this code gives the output "Hello Hello".
A slightly more realistic example can be found below:
In this bytecode, one variable is named "i = 0\n j" making the decompiled implementation of the RC4 function different from the bytecode.
Expected behavior
I expect uncompyle6 to either warn about the presence of improperly named variables or simply rename them by for example replacing all invalid characters with "_".
Environment
OS: Ubuntu 19.04
Additional Environment or Context
I understand that you generally don't support obfuscated Python code but I think this is very simple to implement and does not contribute to making the code more complex. I'd be willing to implement this and provide a PR for this but I would like your opinion if it should be a warning or renaming the variables or maybe even some command line option to choose between the two.