Wrong binding of closure variable with intervening list comprehension
オープン
まだ誰も着手していません。
3.12
3.13
3.14
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
def f(x):
def g():
print([x for x in range(10)])
def h():
print(x)
return h
print(x)
return g
f(1)()()
The above had always bound x in h to the parameter of f. But it no longer works and somehow binds to a local in g, throwing the following error:
NameError: cannot access free variable 'x' where it is not associated with a value in enclosing scope
CPython versions tested on:
3.12
Operating systems tested on:
Linux, Windows
Linked PRs
- gh-124696
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
CPython 3.12 で closure とリスト内包表記の例を再現し、その出力を報告された NameError と比較します。まず、例に関係するスコープとコンパイルパスを確認し、次にリンクされた PR gh-124696 を調査します。例が x を f のパラメーターに束縛し、エラーなしで完了すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100