turtle: TNavigator.degrees(0) raises ZeroDivisionError instead of a clear error
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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