liftoff / pyminifier

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

Obfuscation breaks try ... import #130

Open liam-ly opened 2 years ago

liam-ly commented 2 years ago

The following file

# -*- coding: utf-8 -*-
"""Compatibility layer for optional functionality."""

def _tqdm(it, *_args, **_kwargs):  # noqa
    return it

try:
    from tqdm.auto import tqdm
except ImportError:
    tqdm = _tqdm

__all__ = ["tqdm"]

incorrectly obfuscates to

def R(it,*_args,**_kwargs): 
u=ImportError
 return it
try:
 from tqdm.auto import tqdm
except u:
 w=R
__all__=["tqdm"]
# Created by pyminifier (https://github.com/liftoff/pyminifier)

The exception renaming should be outside of the def R