pprint.isreadable returns True for non-eval-able float and complex specials
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Issue
isreadable is documented as returning True if the object's repr is readable by the interpreter — implying eval(pformat(obj)) == obj. For float and complex non-finite values, isreadable returns True, but the roundtrip fails — eval raises NameError since inf and nan aren't valid Python expressions.
Reproducer
import pprint
print(pprint.isreadable(float('inf'))) # True — but eval('inf') raises NameError
print(pprint.isreadable(float('nan'))) # True
print(pprint.isreadable(complex(float('inf'), 0))) # True
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-145116
- gh-145120
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
pprint.isreadable から始め、非有限の float 値および complex 値について reproducer を実行します。それらの表現がどのように分類されるかを追跡し、表現の評価で NameError が発生する場合に isreadable が値を読み取り可能だと主張しなくなっていることを確認します。これらのケースに対する焦点を絞ったテストを追加または更新します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100