liftoff / pyminifier

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

Problems with first line obfuscation #49

Open sejans opened 8 years ago

sejans commented 8 years ago

File test.py contains:

print("Hello World!")

The result after obfuscation is:

R("Hello World!")
R=print
# Created by pyminifier (https://github.com/liftoff/pyminifier)

Because the lines are in incorrect order, the result is not compiling. NameError: name 'R' is not defined

It seems like there is problem with first line obfuscation, because: 1) If I add import statement as first line, e.g.:

import sys
print("Hello World!")

The result is - OK:

import sys
W=print
W("Hello World!")
# Created by pyminifier (https://github.com/liftoff/pyminifier)

2) If I add comment as first line and use --nominify, then result is also OK (incase --nominify isnt used, then again there is problem, because the comment line is deleted and the same happens) So test.py is:

# yo what a great day
print("Hello World!")

Without --nominify - NOT OK:

H("Hello World!")
H=print
# Created by pyminifier (https://github.com/liftoff/pyminifier)

With --nominify - OK:

# yo what a great day
S=print
S("Hello World!")
# Created by pyminifier (https://github.com/liftoff/pyminifier)

So in result it seems that obfuscation have some problems with first line obfuscation.