python / python/cpython

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

Đang mở
#129,614 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

topic-repl type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện chuỗi thao tác trong terminal bằng Python 3.13, sau đó bắt đầu đọc quá trình tương tác với readline thông qua pdb.py, bdb.py và cmd.py, bao gồm cả RuntimeError đã được báo cáo về việc tái nhập vào readline. Được xem là hoàn thành khi luồng breakpoint không còn khiến REPL không phản hồi hoặc bị crash sau khi nhấn Ctrl+D rồi Ctrl+C, và có kiểm thử hồi quy bao phủ kịch bản này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
cli, devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.