liftoff / pyminifier

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

Variable scope is not checked #99

Open MewX opened 6 years ago

MewX commented 6 years ago

Hi, I just found there's a probability when I use single-character variable.

So, I have codes like this:

...
IDINFO_JSON = "idinfo.json"
...

def main():
    if not os.path.exists(IDINFO_JSON):
        sys.exit(-1)
    ...
    r = requests.post(...)
    ...

...

After pyminifier -O, it potentially becomes this code:

...
r="idinfo.json"
...

def main():
    if not os.path.exists(r):
        G(-1)
    ...
    r = i(...)
    ...

...

And because of the variable scope issue, when i run the codes, it meets an error:

UnboundLocalError: local variable 'r' referenced before assignment