]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111277: In summarize_stats.py, don't fail fast on invalid ratios (#111278)
authorMichael Droettboom <mdboom@gmail.com>
Tue, 31 Oct 2023 00:10:07 +0000 (20:10 -0400)
committerGitHub <noreply@github.com>
Tue, 31 Oct 2023 00:10:07 +0000 (17:10 -0700)
Tools/scripts/summarize_stats.py

index 0527d4bebfb86e634df5ed5345db5089967a5c52..360b7c720bd1f094f5048af1cdfd0ff0a0184c85 100644 (file)
@@ -421,8 +421,6 @@ class Ratio:
         self.num = num
         self.den = den
         self.percentage = percentage
-        if den == 0 and num != 0:
-            raise ValueError("Invalid denominator")
 
     def __float__(self):
         if self.den == 0:
@@ -433,7 +431,11 @@ class Ratio:
             return self.num / self.den
 
     def markdown(self) -> str:
-        if self.den == 0 or self.den is None:
+        if self.den is None:
+            return ""
+        elif self.den == 0:
+            if self.num != 0:
+                return f"{self.num:,} / 0 !!"
             return ""
         elif self.percentage:
             return f"{self.num / self.den:,.01%}"