pyminifier icon indicating copy to clipboard operation
pyminifier copied to clipboard

fix a ZeroDivisonError when cumulative_size is zero

Open afq984 opened this issue 8 years ago • 0 comments

If the cumulative size is 0, the program will crash with ZeroDivisionError

The PR should fix that.

afg@sceptile ~/p/pyminifier (master)> 
python -m pyminifier __init__.py empty.py 
__init__.py (0) reduced to 64 bytes (0% of original size)
empty.py (0) reduced to 64 bytes (0% of original size)
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/afg/projects/pyminifier/pyminifier/__main__.py", line 175, in <module>
    main()
  File "/home/afg/projects/pyminifier/pyminifier/__main__.py", line 171, in main
    pyminify(options, files)
  File "/home/afg/projects/pyminifier/pyminifier/__init__.py", line 271, in pyminify
    (float(cumulative_new) / float(cumulative_size) * 100), 2)
ZeroDivisionError: float division by zero

afq984 avatar Aug 04 '17 02:08 afq984