From 2d55fd2e851a6f94e5acf4757998a3ba75d87896 Mon Sep 17 00:00:00 2001 From: evdakim1234 <95436071+evdakim1234@users.noreply.github.com> Date: Thu, 10 Sep 2026 03:30:53 +0300 Subject: [PATCH] Fix potential division by zero in turtle.py --- Lib/turtle.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/turtle.py b/Lib/turtle.py index b49df26bd07bc5a..f6e5f91c7385f48 100644 --- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -1095,6 +1095,8 @@ def setworldcoordinates(self, llx, lly, urx, ury): self.mode("world") xspan = float(urx - llx) yspan = float(ury - lly) + if xspan == 0 or yspan == 0: + raise ValueError("Width and height must be greater than zero") wx, wy = self._window_size() self.screensize(wx-20, wy-20) oldxscale, oldyscale = self.xscale, self.yscale @@ -2055,6 +2057,8 @@ def circle(self, radius, extent = None, steps = None): if steps is None: frac = abs(extent)/self._fullcircle steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac) + if steps == 0: + raise ValueError("steps must not be zero") w = 1.0 * extent / steps w2 = 0.5 * w l = 2.0 * radius * math.sin(math.radians(w2)*self._degreesPerAU)