From 696f91151c6fe3d885fc658056c3fd19aceb4943 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Dec 1991 17:25:52 +0000 Subject: [PATCH] Fix division by zero in some cases. --- Demo/sgi/video/video.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Demo/sgi/video/video.py b/Demo/sgi/video/video.py index d9872d5ef05..da2d2c72336 100755 --- a/Demo/sgi/video/video.py +++ b/Demo/sgi/video/video.py @@ -98,11 +98,12 @@ def initcmap(ybits,ibits,qbits,chrompack): for y in range(maxy): yv = float(y)/float(maxy-1) for i in range(maxi): - iv = (float(i)/float(maxi-1))-0.5 + if maxi = 1: iv = 0 + else: iv = (float(i)/float(maxi-1))-0.5 for q in range(maxq): - qv = (float(q)/float(maxq-1))-0.5 + if maxq = 1: qv = 0 + else: qv = (float(q)/float(maxq-1))-0.5 index = 2048 + y + (i << ybits) + (q << (ybits+ibits)) - rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv) r,g,b = int(rv*255.0), int(gv*255.0), int(bv*255.0) if index < 4096 - 256: