python / python/cpython

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

オープン
#129,614 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

topic-repl type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
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. リポジトリをフォークし、ブランチを切って変更します。
  4. 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 を短くまとめたダイジェスト。