python / python/cpython

pdb: "until" does not step over a list comprehension with a breakpoint set on it

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

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

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

説明

Bug report

When a breakpoint is set on a line that holds a list comprehension (or any
single-line loop), the until command stops on that same line again on every
iteration instead of moving past it.

Reproduction:

# repro.py
def f():
    lst = [i for i in range(10)]
    for i in lst: pass

f()
$ python -m pdb repro.py
> repro.py(1)<module>()
-> def f():
(Pdb) break 2
Breakpoint 1 at repro.py:2
(Pdb) continue
> repro.py(2)f()
-> lst = [i for i in range(10)]
(Pdb) until
> repro.py(2)f()
-> lst = [i for i in range(10)]
(Pdb) until
> repro.py(2)f()
-> lst = [i for i in range(10)]

until keeps stopping on line 2, once per comprehension element.

Expected: until moves past the comprehension to the next line, the way next
and step already do (gh-136057, gh-136160). This also matches gdb, which
pdb's until is borrowed from: there, until steps past a single-line loop
to the next line even with a breakpoint set on it, instead of stopping on each
iteration.

I have a small fix for this and can open a PR.

Linked PRs
  • gh-152374

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

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

はじめの一歩

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

調査の方向性

pdbのエントリポイントから始め、repro.pyを使って動作を再現し、リスト内包表記の行にブレークポイントを設定してuntilを繰り返し実行します。issueの説明にあるとおり、untilとnextおよびstepを比較します。untilが内包表記の各要素で停止せず、次の行へ進むようになれば完了です。リンクされたPRはすでに記録されています。

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

評価

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

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

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