pyminifier icon indicating copy to clipboard operation
pyminifier copied to clipboard

Variable scope is not checked

Open MewX opened this issue 8 years ago • 0 comments

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

MewX avatar Jan 14 '18 00:01 MewX