Skip to content

gh-157244: Fix potential division by zero in turtle.py - #157245

Closed
evdakim1234 wants to merge 1 commit into
python:mainfrom
evdakim1234:fix-issue-#157244
Closed

gh-157244: Fix potential division by zero in turtle.py#157245
evdakim1234 wants to merge 1 commit into
python:mainfrom
evdakim1234:fix-issue-#157244

Conversation

@evdakim1234

@evdakim1234 evdakim1234 commented Sep 10, 2026

Copy link
Copy Markdown

Fixes #157244

This PR adds guard clauses to prevent potential ZeroDivisionError exceptions in the turtle module:

-Validates xspan and yspan in setworldcoordinates to prevent division by zero during coordinate scaling.
-Validates steps in circle before using it as a denominator.
(Backport request: to 3.13).

@python-cla-bot

python-cla-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Sep 10, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@aisk

aisk commented Sep 10, 2026

Copy link
Copy Markdown
Member

I'm not sure changing the DevideByZero to ValueError is the right solution and meaningful, but if we decided to merge this, a test and a news entry is required.

@encukou

encukou commented Sep 10, 2026

Copy link
Copy Markdown
Member

No, replacing ZeroDivisionError by ValueError is not meaningful.

@encukou encukou closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potencial division by zero in turtle.py

3 participants