python / python/cpython

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

未关闭
#152,373 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 pdb 入口点开始,使用 repro.py 重现该行为,在列表推导式所在行设置断点,并反复运行 until。按照 issue 中的描述,将 until 与 next 和 step 进行比较。当 until 前进到下一行,而不是在每个推导式元素处停止时,即表示完成;已记录一个关联的 PR。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。