liftoff / pyminifier

Pyminifier is a Python code minifier, obfuscator, and compressor.
GNU General Public License v3.0
1.43k stars 221 forks source link

Multiple file obfuscation creates code with identation error #146

Open sylvainmouretfico opened 1 year ago

sylvainmouretfico commented 1 year ago

Hey, I have a very simple example, where the result is not proper Python code.

Here are the steps to reproduce.

main.py

import sub
sub.doSomething()

sub.py

def doSomething():
    print("test")
$ pyminifier --version
2.1
$ pyminifier -d out -O *.py
$ cd out
$ python main.py
Traceback (most recent call last):
  File "xxx\out\main.py", line 1, in <module>
    import sub
  File "xxx\out\sub.py", line 2
    i=print
    ^
IndentationError: expected an indented block after function definition on line 1

Result:

main.py

import sub
D=sub.D
D()

sub.py

def D():
i=print
 i("test")`

Note that the line i=print is not properly indented.