python / python/cpython

turtle: TNavigator.degrees(0) raises ZeroDivisionError instead of a clear error

Open
#152,037 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-tkinter type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

turtle.TNavigator.degrees(fullcircle) — the public Turtle.degrees / turtle.degrees — divides
360 / fullcircle in _setDegreesPerAU without checking fullcircle, so passing 0 raises a
ZeroDivisionError that leaks the implementation rather than reporting the invalid argument:

>>> import turtle
>>> turtle.TNavigator().degrees(0)
Traceback (most recent call last):
  ...
ZeroDivisionError: division by zero

degrees documents fullcircle only as "a number", and 0 reaches the division directly through the
public API. It should raise a clear ValueError instead. The companion radians() passes math.tau,
so it is unaffected.

CPython versions tested on:

3.12, 3.14 (main)

Operating systems tested on:

Linux

Linked PRs
  • gh-152038

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at turtle.TNavigator.degrees and the _setDegreesPerAU path described in the report, then run the provided turtle.TNavigator().degrees(0) reproduction. Done means zero is rejected through the public degrees API with a clear ValueError rather than ZeroDivisionError; check the companion radians() behavior remains unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.