IDLE - there is no known way to trigger atexit functions
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Hello!
So this has been an issue that has probably been bugging many people for a while now. This has bitten me back when I was a newbie as well, learning python using IDLE. This issue does not personally affect me anymore since I've mostly moved on from IDLE, but for the sake of others new to the language, I would like to formalise this issue on the tracker.
Here is a pure python MRE that demonstrates what I'm saying
import atexit
import time
@atexit.register
def done():
print("Exiting application!")
time.sleep(1)
When I run this on the command-line with no flags, I see the text printed after the program runs for a second and exits. On IDLE, this just runs for a second and exits without printing anything.
So I later realised that IDLE runs programs with the -i flag. But on the commandline I can do a ctrl+z and get the interpreter to actually stop and handle atexit. This is not apparent in IDLE shell, where there does not seem to be any distinction between the "regular interactive state", and the "previous module run interactive state". And neither does ctrl+c/z/d work. A hard shell restart also does not lead to anything being printed.
I've glanced through the issue tracker with a quick search and I didn't find a duplicate of this issue, but incase I'm mistaken, my apologies; this issue can be closed.
Your environment
- CPython versions tested on: 3.10 (but from my memory, it happened on all previous versions too)
- Operating system and architecture: Windows 11 64-bit (In my understanding it also happens on other architectures and OSes)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 IDLE 中以及通过命令行运行提供的纯 Python atexit 复现程序,然后比较 IDLE shell 的常规状态和模块运行后的状态。完成标准是:IDLE 提供一种清晰的方式来进入执行已注册 atexit 函数的解释器状态,并且报告的输出会在模块退出后出现。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- desktop, tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100