python / python/cpython

`pdb` commands may try to access non-existing frames

未关闭
#138,641 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib type-bug
主要语言
Python
星标
77.2k
派生
36k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:
➜  cpython git:(main) ./python.exe
Python 3.15.0a0 (heads/main:919c7e806e, Sep  8 2025, 17:24:03) [Clang 17.0.0 (clang-1700.0.13.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> breakpoint()
> <python-input-0>(1)<module>()
(Pdb) breakpoint()
(Pdb) ll
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    breakpoint()
    ~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/bdb.py", line 94, in wrapper
    ret = func(frame, *args)
  File "/Users/hyi/prs/cpython/Lib/bdb.py", line 154, in opcode_callback
    frame.f_trace(frame, 'opcode', None)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/bdb.py", line 289, in trace_dispatch
    return self.dispatch_opcode(frame, arg)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/bdb.py", line 406, in dispatch_opcode
    self.user_opcode(frame)
    ~~~~~~~~~~~~~~~~^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/pdb.py", line 547, in user_line
    self.interaction(frame, None)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/pdb.py", line 736, in interaction
    self._cmdloop()
    ~~~~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/pdb.py", line 601, in _cmdloop
    self.cmdloop()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/cmd.py", line 149, in cmdloop
    stop = self.onecmd(line)
  File "/Users/hyi/prs/cpython/Lib/pdb.py", line 1038, in onecmd
    return cmd.Cmd.onecmd(self, line)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/cmd.py", line 227, in onecmd
    return func(arg)
  File "/Users/hyi/prs/cpython/Lib/pdb.py", line 2156, in do_longlist
    filename = self.curframe.f_code.co_filename
               ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'f_code'
>>> 
CPython versions tested on:

3.15, CPython main branch

Operating systems tested on:

Other

Linked PRs
  • gh-138642

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Lib/pdb.py 的 do_longlist 开始,检查通过命令循环到达的 frame 状态;traceback 还指出 Lib/bdb.py 是调用路径的一部分。重现 breakpoint() 和 ll 序列,然后验证在不存在当前 frame 时,pdb 命令不再引发 AttributeError。

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

评估

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

把新 issue 发到你的邮箱

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