Skip to content

Division by zero in ProgressBar.percentage #38

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions