[diffoscope] 02/02: progressbar: avoid div-by-zero

Ximin Luo infinity0 at debian.org
Mon May 29 22:24:28 CEST 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch experimental
in repository diffoscope.

commit ad1ed219efad36a1815f0701d5c55e2c65e91a66
Author: Ximin Luo <infinity0 at debian.org>
Date:   Mon May 29 22:24:07 2017 +0200

    progressbar: avoid div-by-zero
---
 diffoscope/progress.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/diffoscope/progress.py b/diffoscope/progress.py
index 38b7a29..b00dd48 100644
--- a/diffoscope/progress.py
+++ b/diffoscope/progress.py
@@ -149,6 +149,7 @@ class Progress(object):
                 # cost of what we expect will have been done, once the current in-progress
                 # step plus all of its children, have completed
                 expected_all_done = all_done + (cur_child_total - cur_child_done)
+                assert own_done # non-zero
                 return all_done, int(float(self.total) / own_done * expected_all_done)
             else:
                 pass # nothing in progress
@@ -156,6 +157,10 @@ class Progress(object):
             # nothing in progress
             assert not cur_child_estimate
 
+        if not own_done:
+            assert not children_done
+            return 0, self.total
+
         # weigh self.total by (all_done/own_done)
         return all_done, int(float(self.total) / own_done * all_done)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list