From 6ac3a170ae635904a3a216e9fc284092904c801e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Fri, 2 Jun 2023 08:36:28 +0300
Subject: [PATCH 1/1] Fixed divide-by-zero in poll results with zero votes
IssueID #85
50_bubble.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/50_bubble.py b/50_bubble.py
index ca5a4f5..68ecac6 100644
--- a/50_bubble.py
+++ b/50_bubble.py
@@ -335,7 +335,7 @@ Bubble is open source:
total_votes += option.counter
total_votes_msg = ''
if total_votes == 0 and not show_results:
if total_votes == 0:
total_votes_msg = 'No votes have been cast.\n'
else:
total_votes_msg = f'{total_votes} vote{plural_s(total_votes)} {("was" if total_votes==1 else "were") if show_results else ("have been" if total_votes != 1 else "has been")} cast.\n'
@@ -368,7 +368,7 @@ Bubble is open source:
BG = '\u2581'
WIDTH = 24
share = option.counter / total_votes
share = option.counter / total_votes if total_votes else 0
pos = round(share * WIDTH)
src += FG * pos + BG * (WIDTH - pos) + (' %d%%' % round(share * 100)) + '\n'
--
2.25.1
text/plain
This content has been proxied by September (3851b).