python / python/cpython

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

オープン
#152,037 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib topic-tkinter type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

turtle.TNavigator.degrees と、レポートで説明されている _setDegreesPerAU の経路から始め、続いて提供されている turtle.TNavigator().degrees(0) の再現を実行します。完了条件は、公開されている degrees API を通じてゼロが ZeroDivisionError ではなく明確な ValueError として拒否されることです。対応する radians() の動作に影響がないことを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。