Skip to content

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

Description

@CharlesCNorton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions