python / python/cpython

New REPL crashes on an empty DELETE_WORD_BACKWARDS (^W) followed by CLEAR_TO_START (^K)

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

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

3.13 3.14 stdlib 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:

If, in the REPL, you:

  1. Delete the current word, backward, on an empty line using Control-W, then
  2. Delete to the end of line, using Control-K

The REPL will crash with an exception in readline.

Note: ^ denotes pressing the Control or Command key when pressing the next character.

>>> ^W^KTraceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib64/python3.13/_pyrepl/__main__.py", line 6, in <module>
    __pyrepl_interactive_console()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/main.py", line 59, in interactive_console
    run_multiline_interactive_console(console)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib64/python3.13/_pyrepl/simple_interact.py", line 143, in run_multiline_interactive_console
    statement = multiline_input(more_lines, ps1, ps2)
  File "/usr/lib64/python3.13/_pyrepl/readline.py", line 389, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/reader.py", line 802, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/reader.py", line 785, in handle1
    self.do_cmd(cmd)
    ~~~~~~~~~~~^^^^^
  File "/usr/lib64/python3.13/_pyrepl/reader.py", line 710, in do_cmd
    command.do()
    ~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/commands.py", line 157, in do
    self.kill_range(r.pos, eol + 1)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/_pyrepl/commands.py", line 71, in kill_range
    r.kill_ring[-1] = r.kill_ring[-1] + text
                      ~~~~~~~~~~~^^^^

This exception is caused since kill_range is not called on an empty backward_kill_word, causing kill_ring to be empty: https://github.com/pypy/pyrepl/blob/ca192a80b76700118b9bfd261a3d098b92ccfc31/pyrepl/commands.py#L152-L156

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs
  • gh-131452

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

Bắt đầu trong pyrepl/commands.py, khoảng các dòng 152-156, nơi mô tả việc xóa từ theo hướng ngược và kill_range. Tái hiện chuỗi ^W theo sau bởi ^K trên một dòng trống trong REPL và theo dõi trạng thái của kill-ring. Hoàn tất khi chuỗi này không còn gây ra ngoại lệ readline đã báo cáo; PR được liên kết gh-131452 cho biết công việc đã được tiến hành.

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
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
30/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.