OSDN Git Service

Fix zero division.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Fri, 18 Aug 2006 06:12:44 +0000 (15:12 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Fri, 18 Aug 2006 06:12:44 +0000 (15:12 +0900)
src/Hage1/board_window.py

index 1f45821..afb58b4 100644 (file)
@@ -193,7 +193,13 @@ class WinWrap:
             else:
                 res = dic["res"]
                 start = int(id)
             else:
                 res = dic["res"]
                 start = int(id)
-                dic["average"] = int(res * 60 * 60 * 24 / (lastmod - start))
+                # avoid the Last-Modified time of subject.txt and
+                # the build time of thread is equal (zero division)
+                dur = lastmod - start
+                if dur == 0:
+                    dic["average"] = 999999
+                else:
+                    dic["average"] = int(res * 60 * 60 * 24 / dur)
 
             # lastModified
             httpdate = dic["lastModified"]
 
             # lastModified
             httpdate = dic["lastModified"]