python / python/cpython

python -m asyncio and breakpoint() will fovever error loop and mess up the terminal

未关闭
#138,827 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

  • #138617 来自 @yihong0618 —— 已关闭,未合并
stdlib topic-repl type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:
# Add a code block here, if required
➜  cpython git:(main) ./python.exe -m asyncio
asyncio REPL 3.15.0a0 (heads/hy/close_new_repl_error_mess:b194f8fae6, Sep 12 2025, 19:50:01) [Clang 17.0.0 (clang-1700.0.13.5)] on darwin
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> breakpoint()
> <python-input-0>(1)<module>()
(Pdb) n
--Return--
> <python-input-0>(1)<module>()->None
(Pdb) n
> /Users/yihong/repos/cpython/Lib/asyncio/__main__.py(57)callback()
-> if not inspect.iscoroutine(coro):
(Pdb) n
> /Users/yihong/repos/cpython/Lib/asyncio/__main__.py(58)callback()
-> future.set_result(coro)
(Pdb)

then type n twice the terminal will boom

Image
CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用 ./python.exe -m asynciobreakpoint(),并在 Pdb 提示符中执行两条 n 命令来复现。阅读 Lib/asyncio/__main__.pycallback() 第 57-58 行附近的代码,并检查报告中显示的终端行为;完成的标准是 asyncio REPL 在此流程中不再出现损坏或反复报错。

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

评估

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

把新 issue 发到你的邮箱

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