Improve suggestion in NameError when deleting builtins
オープン
まだ誰も着手していません。
interpreter-core
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
When deleting a name, python will only find the name in globals and locals, no builtins. However, the suggestion generating code just combined these dict, which makes the suggestion cycle:
>>> del next
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
del next
^^^^
NameError: name 'next' is not defined. Did you mean: 'anext'?
>>> del anext
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
del anext
^^^^^
NameError: name 'anext' is not defined. Did you mean: 'next'?
According to DPO, the best way to fix this bug is using dis to analyse the last traceback to get the final operation.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-141389
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
del next と del anext で問題を再現し、NameError の候補生成パスを調査してから、dis を使って traceback から最後の操作を特定します。リンクされた PR gh-141389 のアプローチと比較します。削除された builtin が代替候補として提案されなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100