sundeep15 / python-progressbar

Automatically exported from code.google.com/p/python-progressbar
Other
0 stars 0 forks source link

Division by zero in `ProgressBar.percentage` #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if this division by zero was avoided:

diff --git a/progressbar/progressbar.py b/progressbar/progressbar.py
--- a/progressbar/progressbar.py
+++ b/progressbar/progressbar.py
@@ -184,7 +184,7 @@

     def percentage(self):
         """Returns the progress as a percentage."""
-        if self.currval >= self.maxval:
+        if self.currval >= self.maxval or self.maxval == 0:
             return 100.0
         return self.currval * 100.0 / self.maxval

Original issue reported on code.google.com by wole...@gmail.com on 8 Aug 2014 at 6:57