Skip to content

Commit 2d55fd2

Browse files
authored
Fix potential division by zero in turtle.py
1 parent 24e5a55 commit 2d55fd2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/turtle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,8 @@ def setworldcoordinates(self, llx, lly, urx, ury):
10951095
self.mode("world")
10961096
xspan = float(urx - llx)
10971097
yspan = float(ury - lly)
1098+
if xspan == 0 or yspan == 0:
1099+
raise ValueError("Width and height must be greater than zero")
10981100
wx, wy = self._window_size()
10991101
self.screensize(wx-20, wy-20)
11001102
oldxscale, oldyscale = self.xscale, self.yscale
@@ -2055,6 +2057,8 @@ def circle(self, radius, extent = None, steps = None):
20552057
if steps is None:
20562058
frac = abs(extent)/self._fullcircle
20572059
steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac)
2060+
if steps == 0:
2061+
raise ValueError("steps must not be zero")
20582062
w = 1.0 * extent / steps
20592063
w2 = 0.5 * w
20602064
l = 2.0 * radius * math.sin(math.radians(w2)*self._degreesPerAU)

0 commit comments

Comments
 (0)