python / python/cpython

New REPL crash (and terminal display issues) after a breakpoint and by sending Ctrl + D input

未關閉
#129,614 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

topic-repl type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

In a really specific scenario, the terminal can go crazy and becomes unresponsive:

https://github.com/user-attachments/assets/d9986c12-aa66-4e3c-bc69-840af79eec95

Steps to reproduce:

  • Create an issue.py file, with a breakpoint set (echo 'breakpoint()' > issue.py).
  • Run issue.py in interactive mode: python -i issue.py
  • Press C to continue when hitting the breakpoint.
  • Start typing something, e.g. help(
  • Input Ctrl + D, as if you wanted to exit the terminal. Nothing happens (as it should).
  • Input Ctrl + C, as if you wanted to clear the line.

If no breakpoint was hit before, this works as expected:

>>> help(  # hit Ctrl + D then Ctrl + C
KeyboardInterrupt

Note trying to reproduce on Python 3.12, the following happens:

--Return--
> /home/victorien/ws/pydantic/issue.py(1)<module>()->None
-> breakpoint()
(Pdb) c
>>> help(  # hit Ctrl + D then Ctrl + C
Program interrupted. (Use 'cont' to resume).
--Return--
> /home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/pdb.py(271)sigint_handler()->None
-> self.set_trace(frame)

Traceback (most recent call last):
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/pdb.py", line 271, in sigint_handler
    self.set_trace(frame)
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/bdb.py", line 94, in trace_dispatch
    return self.dispatch_return(frame, arg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/bdb.py", line 153, in dispatch_return
    self.user_return(frame, arg)
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/pdb.py", line 362, in user_return
    self.interaction(frame, None)
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/pdb.py", line 428, in interaction
    self._cmdloop()
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/pdb.py", line 390, in _cmdloop
    self.cmdloop()
  File "/home/victorien/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/cmd.py", line 126, in cmdloop
    line = input(self.prompt)
           ^^^^^^^^^^^^^^^^^^
RuntimeError: can't re-enter readline
>>> 

CPython versions tested on:

3.13

Operating systems tested on:

Linux

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用 Python 3.13 重現終端序列,然後先透過 pdb.py、bdb.py 和 cmd.py 閱讀 readline 互動,包括所回報的重新進入 readline 的 RuntimeError。完成的標準是:按下 Ctrl+D 後再按 Ctrl+C 時,中斷點流程不再讓 REPL 沒有回應或當機,並且有涵蓋此情境的回歸測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli, devtools
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。