liftoff / pyminifier

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

IndentationError: unexpected indent with 'pip' v2.1 and 'git' v2.2 #90

Open GONQULATOR opened 7 years ago

GONQULATOR commented 7 years ago
$ python deleteme2.py 
  File "deleteme2.py", line 21
    print "Balance: "+H(b)
    ^
IndentationError: unexpected indent

Version from pip, freshly installed:

$ pyminifier --version
2.1

INPUT FILE: deleteme.py -- OUTPUT FILE: deleteme2.py

$ pyminifier -O deleteme.py > deleteme2.py
$ python deleteme2.py 
  File "deleteme2.py", line 21
    print "Balance: "+p(b)
    ^
IndentationError: unexpected indent

INPUT FILE

import random
import time

def runtix():
    balance = 0
    count = 0

    while (count < 9999):

        count += 1

        randNum = random.randrange(0, 99)

        randSeed = random.randrange(0, 99)

        randCorn = random.randrange(0, 99)

        if (int(randNum) - int(randSeed) - int(randCorn) == 0):
            balance += 1
            print "Randoms:  " + str(randNum) + " : " + str(randSeed) + " : " + str(randCorn)
            print "Balance: " + str(balance)
            print "Count: " + str(count)
            print time.time()

            ''' # Commented out for testing
            print str(randNum)
            print str(randSeed)
            print "Equals : 0"
            print "\n\n"
            print "Balance: " + str(balance)
            print "Count: " + str(count)
            print "--------/n"
            '''
    print "Balance: " + str(balance)
    print "Count: " + str(count)
    print time.time()
runtix()

This script executes perfectly.

OUTPUT FILE: deleteme2.py throws indentation error:

import random
r=int
p=str
c=random.randrange
import time
S=time.time
def s():
 b=0
 K=0
 while(K<9999):
  K+=1
  J=c(0,99)
  t=c(0,99)
  C=c(0,99)
  if(r(J)-r(t)-r(C)==0):
   b+=1
   print "Randoms:  "+p(J)+" : "+p(t)+" : "+p(C)
   print "Balance: "+p(b)
   print "Count: "+p(K)
   print S()
    print "Balance: "+p(b)
 print "Count: "+p(K)
 print S()
s()
# Created by pyminifier (https://github.com/liftoff/pyminifier)

The resulting output gives a Python indentation error whether I use the default or the '--use-tabs' flag. It also gives different incorrect indent margins on different lines/blocks.

I cloned the version from the .git repo. I installed it:

$ pyminifier --version
2.2

I get the same errors on the same input / output code. Version 2.2 generated this code:

import random
s=int
m=str
A=random.randrange
import time
Y=time.time
def Q():
 J=0
 X=0
 while(X<9999):
  X+=1
  i=A(0,99)
  n=A(0,99)
  w=A(0,99)
  if(s(i)-s(n)-s(w)==0):
   J+=1
   print "Randoms:  "+m(i)+" : "+m(n)+" : "+m(w)
   print "Balance: "+m(J)
   print "Count: "+m(X)
   print Y()
    print "Balance: "+m(J)
 print "Count: "+m(X)
 print Y()
Q()
# Created by pyminifier (https://github.com/liftoff/pyminifier)
land-pack commented 6 years ago

Did you fixed it ?