Make the capability of getting the source of interactive code public
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
In #117500, we create a nice mechanism to register and retrieve the source code of an arbitrary code object. It was a bug fix so we want to keep it as private as possible - it was for PyREPL usage only. However, we did put effort into the design so it can be used in a wider range in the future, and now is the future!
We just passed beta freeze so we have enough time to make it a new feature. The code and mechanism is really simple, it's just about documentation (and whether we want to merge some interfaces).
There are two orthogonal areas I want to bring into discussion, for each I have two proposals:
- How do we want the interface
- Keep it as it is, meaning the user needs to explicitly register and retrieve source code from a complete separate pair of interfaces.
- Combine
getlinesand_getline_from_code, making code an optional argument togetlines- take the path when the optional code object is passed in.
- How public do we want it to be
- Make it public to all users.
- Make it public internally so at least
inspectandpdbcan use it. (we don't document it, but we keepinspect.getsourcelineswork)
In either combination, we have the full backwards compatibility - nothing will be broken. It's more about how much maintenance effort we want to put in and how easy we want the user to use the feature.
An obvious example usage is that, if you want to debug some interactive code, either through pdb.run(), or debug command in pdb. You don't have the source code symbols now, even though it's fully available. With this capability, we can make pdb.run() work nicely with string source code.
cc: @pablogsal
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 PR #117500 开始,检查用于注册和检索交互式源代码的现有机制。比较提议的 getlines/_getline_from_code 接口,并考虑 inspect 和 pdb 将如何使用它们。完成的标准是确定接口和公开性策略、在适当情况下为该功能编写文档,并定义 pdb.run() 或调试行为的预期表现。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100