microsoft / microsoft/vscode-python-debugger

Prevent vscode from exiting the Python interpreter a script completes

未关闭
#524 9 条评论 41 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature-request needs PR
主要语言
TypeScript
星标
181
派生
126
平均合并
2 天 3 小时
30 天内合并 PR
3

描述

Discussed in https://github.com/microsoft/vscode-python/discussions/16082

Originally posted by larsoner April 29, 2021
The way I have used Python for years (through Spyder, directly from a bash terminal, etc.) is to execute a script in interactive mode such that once it's done, you can interact with it, e.g.:

python -i script.py

VSCode's debugger does not give a way to get this behavior currently. And it seems like I am not the only one looking for it:

One workaround is to put a breakpoint at the end of your file, but this requires extra work.

Another workaround is to add "env": {"PYTHONINSPECT": "true"}, to the launch configuration with integratedTerminal, but this doesn't work properly as any input is captured and newlines aren't treated properly while printing, which makes it pretty unusable.

I could see at least two potential solutions (the first would be better I think):

  1. Make it so that in PYTHONINSPECT mode, the terminal could be interacted with properly, possibly by adding a new inspectOnExit or something that ran in -i / PYTHONINSPECT mode and returned proper input/output when the script completes. Based on https://github.com/microsoft/vscode-python/issues/5497 it sounds like this is a no-go, though.
  2. Add a stopOnExit debug option to mirror stopOnEntry in the debugger. This way at least variables could be inspected using the vscode debugger.

贡献指南

打开贡献指南

从这里开始

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

调研方向

Issue 中没有指定实现文件或测试。首先查看链接的讨论以及现有的 stopOnEntry 调试器行为,然后将提议的交互式 PYTHONINSPECT 和 stopOnExit 方案与 issue 5497 进行比较。Done 应提供可用的脚本结束后检查体验,而不要求在末尾设置 breakpoint。

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

评估

技术栈
typescript
领域
devtools
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

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