python / python/cpython

PYTHONBREAKPOINT should ignore non-importable breakpoints

未關閉
#126,177 8 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:

I'd like to use ipdb rather than the built-in pdb by default for my breakpoints. However, if I set PYTHONBREAKPOINT="ipdb.set_trace" as a global shell environment variable, and the project does not have ipdb available, then all breakpoints are disabled:

/Users/tomforbes/.../cli.py:144: RuntimeWarning: Ignoring unimportable $PYTHONBREAKPOINT: "ipdb.set_trace"
  breakpoint()

IMO this isn't very user-friendly and can be quite annoying: I need to remember to export it on a per-project or per-shell basis. It would be great to fall back to the standard pdb breakpoint handler if the import fails.

If this is a compatability issue, perhaps a new PYTHONDEFAULTBREAKPOINT env variable could be added (and that can be set globally), which is used if available and falls back to pdb if not?

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先追蹤呼叫 breakpoint() 時 PYTHONBREAKPOINT 的處理方式,包括針對無法匯入的 handler 現有的 RuntimeWarning。定義 ipdb.set_trace 不可用時的 fallback 行為,同時保留標準的 pdb handler,並為可匯入和不可用的 breakpoint handler 都新增涵蓋測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
developer-experience
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。