External pager resets custom SIGINT handlers to SIG_DFL

未关闭 适合新手
#723 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@hugosmoreira 已经在做这个了。

开始于 2026年10月26日。

  • #725 来自 @hugosmoreira —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
cli

调研方向

从 More() 开始,在 fire/console/console_io.py 中检查外部分页器的运行方式以及异常处理方式。在 SIGINT 被忽略之前保存当前活动的处理程序,然后确保分页器退出后恢复该处理程序,包括发生异常时。完成的标准是两种情况下之前的处理程序都仍处于安装状态;issue 没有提供测试文件,因此请为此行为确定一个合适的测试。

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

描述

In fire/console/console_io.py, the More() function temporarily ignores SIGINT while an external pager runs.

However, it restores SIG_DFL instead of the handler previously installed by the application.

Problematic code
signal.signal(signal.SIGINT, signal.SIG_IGN)

# Execute external pager

signal.signal(signal.SIGINT, signal.SIG_DFL)
Expected behavior

The function should preserve the existing signal handler and restore it after the pager exits, including when an exception occurs.

Actual behavior

Based on the code, applications using custom SIGINT handlers lose their original handler after pager execution. Exceptions may also leave SIGINT ignored.

Suggested fix

Save the original handler and restore it in a finally block.

Testing

Identified through source-code inspection. An interactive pager reproduction has not yet been executed.

主要语言
Python
星标
28.2k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

google/python-fire 的其他 Issue

查看 google/python-fire 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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