Pausing or adding new breakpoints halfway during running in VSCode makes the Python Exception lost
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
まず最小限の Python 例を実行し、VSCode の 3 つのフロー(Pause、あらかじめ設定したブレークポイント、実行中にブレークポイントを追加する場合)を再現します。結果として得られる例外処理、特に sys.settrace コールバックのメッセージを比較します。Pause と実行中に追加したブレークポイントが、あらかじめ設定したブレークポイントと同様に RuntimeError を捕捉し、プログラムが一時停止したままにならなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Environment data
- debugpy version: 1.8.13
- OS and version:
Linux abc 5.15.0-139-generic #149 ~20.04.1-Ubuntu SMP Wed Apr 16 08:29:56 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux - Python version (& distribution if applicable, e.g. Anaconda): Python 3.10.18 (miniconda 23.5.2)
- Using VS Code or Visual Studio: VSCode
Actual behavior
Pausing or adding new breakpoints halfway during debugging in VSCode seems to make the Python Exception uncaught.
The following is a minimal example to reproduce my problem.
import contextlib, signal
@contextlib.contextmanager
def time_limit(seconds):
def signal_handler(signum, frame):
raise RuntimeError("Timed out!")
signal.setitimer(signal.ITIMER_REAL, seconds)
signal.signal(signal.SIGALRM, signal_handler)
try:
yield
finally:
signal.setitimer(signal.ITIMER_REAL, 0)
if __name__ == "__main__":
print("start")
try:
with time_limit(10):
a=1
while True:
a = -a
except RuntimeError:
print("timed out")
print("finished")
Different ways of debugging will give different results:
-
Use Pause. The exception is not caught. I click the
pause (F6)halfway through running, and the program pauses on the linea=-aas expected. After several seconds, the time limit is reached, and the RuntimeError is thrown, but the program fails to catch the error. The trackback is printed in the console, but the program is not interrupted (still paused). As a result, the program will run forever after clickingcontinue (F5). -
Use preset breakpoint. The exception is caught. In contrast, if you set a breakpoint at the
a=-a. Run the program, and the program will stop at the breakpoint. Wait a few seconds, and the program will catch the runtime error and finish successfully. The program will continue automatically once it receives the Exception without the user's permission, which is also strange to me. -
Add a breakpoint halfway. The exception is not caught. If you add a new breakpoint at
a=-aafter the program runs for a while, you can find the same behavior as "using Pause". In my opinion, "Pause" may be implemented by "adding a breakpoint halfway"? If this is correct, then this problem may be about "adding a breakpoint while running".
More experimental results:
When using Pause. After pausing, if I switch to the Debug Console, the following message will be thrown when the time limit is reached:
<class 'RuntimeError'> raised from within the callback set in sys.settrace.
Debugging will be disabled for this thread (<_MainThread(MainThread, started 140324903388352)>).
Expected behavior
I expect both 1(Use Pause) and 3(Add a breakpoint halfway) to behave similarly to 2(Use preset breakpoint).
Steps to reproduce:
- As stated in Actual behavior, just try to debug the code in three different ways.
- 主要言語
- Python
- スター
- 2.5k
- フォーク
- 205
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 5
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/debugpy のほかの issue
-
pydevd_comm.py start_client() does not set TCP_NODELAY on the connections it opens対応中かも @nightcityblade が 54 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Document "rules"-option対応中かも @nightcityblade が 42 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
wx.EventLoop() deprecation warning対応中かも @nightcityblade が 41 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
debugpy.configure(python=) is not properly documented対応中かも @nightcityblade が 52 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
microsoft/debugpy の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Deepak3699/Ai_Mentor#244 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
btclib-org/btclib-node#1880 ·
メンテナーはふだん 1 日以内に返信
-
CONTRIBUTING.md: say how ticketless bug fixes and feature PRs are handled対応中かも @khuisman が今日担当しました。 オープンv0.9.2
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
khuisman/mcp-gee-sweet#941 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pyjanitor-devs/pyjanitor#1758 ·
メンテナーはふだん 1 日以内に返信
-
bug ready for review
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
odysseus-dev/odysseus#6641 ·
メンテナーはふだん 1 日以内に返信